std.io

Standard input and output.

Importuse std.io

Functions

extern fn read_line() -> string#

Reads one line from standard input.

fn main() {
  std.io.write("name: ")
  std.io.flush()
  let name = std.io.read_line()
  println("hello " + name)
  let next_four_bytes = std.io.read_exact(4)
  println(next_four_bytes)
  println(std.io.last_read_eof())
}
extern fn read_exact(count: int) -> string#

Reads exactly the requested number of input bytes when available.

  • count: How many bytes to read; a short read returns what was available.
extern fn write(text: string)#

Writes the supplied value.

  • text: Bytes to write to standard output.
extern fn flush()#

Flushes buffered output.

extern fn last_read_eof() -> bool#

Reports whether the last input read reached EOF.