← all modules
module

stdlib::io

defined in C:\Users\bye45\.glide\bin/src/stdlib/io.glide

Read one line from stdin, including the trailing newline if present.

fn fn read_line() -> string

Read one line from stdin, including the trailing newline if present. Returns "" on EOF — callers can disambiguate empty input from EOF only by checking the file descriptor state externally.

glide
import stdlib::io::*;

io_write("name? ");
flush();
let name: string = read_line();
println!("hello,", name.trim());
fn fn prompt(msg: string) -> string

Write a prompt, flush stdout, then read one line from stdin. The returned string does not include a trailing newline.

glide
import stdlib::io::*;

let name: string = prompt("name? ");
println!("hello,", name);
fn fn read_int() -> !int

Read one line from stdin and parse it as an integer. Whitespace is trimmed before parsing.

glide
import stdlib::io::*;

let n: !int = read_int();
if n.ok { println!("number:", n.val); }
else { println!("not an int:", n.err); }
fn fn read_yes_no(prompt_msg: string) -> bool

Prompt for a yes/no response. Returns true when the trimmed response starts with y or Y.

glide
import stdlib::io::*;

if read_yes_no("continue? ") {
    println!("continuing");
}
fn fn read_bytes(n: int) -> string

Read up to n raw bytes from stdin. The returned string is the actual chunk read (may be shorter than n near EOF). Caller owns the memory.

glide
let chunk: string = read_bytes(4096);   // tail of the stdin pipe
fn fn io_write(s: string)

Write s to stdout without buffering a newline. Cheaper than print! when you don't need format inference. Named io_write (not write) so it doesn't collide with the libc write(2) declaration in <io.h>.

glide
io_write("loading ");
for i in 0..3 { io_write("."); flush(); sleep_ms(200); }
io_write(" done\n");
fn fn io_write_bytes(s: string, n: int)

Write exactly n bytes from s to stdout. Use this for binary payloads where the string may contain embedded NULs.

glide
Echo a 16-byte header verbatim.
io_write_bytes(buf, 16);
fn fn flush()

Force-flush the stdout buffer. Stdout is line-buffered when attached to a TTY but block-buffered when piped, so explicit flush() matters for progress indicators and interactive REPLs.

glide
io_write("> ");   // no newline — without flush, prompt won't show

flush();
let cmd: string = read_line();
fn fn eprintln(s: string)

Write s to stderr with a trailing newline. Stderr is unbuffered, so no flush is needed. Use this for log lines that must not interleave with normal println! stdout output.

glide
eprintln("warning: missing config file, using defaults");