Lowent Manual←↑→

stdio — standard input and output

Source
lib/stdio.low
Layer
L2 — host (wrappers over builtin ops)
Capabilities
both ops take cap io

Two ops that reach the three channels a process is born with: 0 (input), 1 (output) and 2 (error). Writing to the screen and reading input cannot be written in the language, so the compiler offers them as builtin ops (call_builtin write_out, call_builtin read_in) and a program calls the ops of this module. A wrapper passes its arguments through unchanged; in native code the C compiler inlines it, so it costs nothing.

use stdio .

proc main input out cap io . output u8 . effects io . do
  let n usize stdio.write out. 1 "hello\n" . .
  return 0 .
end .
opshapenotes
write_out(cap io, d u64, b slice u8) → usizeWrites to channel d. Returns the number of bytes written: on a pipe it may be less than len b. ., and 0 means “cannot write any more”
read_in(cap io, d u64, dst mut slice u8) → option usizeReads from channel d. 0 is the end of input; none means the read failed

Table 50.1 — The ops of stdio

Writing to the end (write_all) and buffered writing live in outbuf cutting the bytes into lines lives in io.

Not built: formatted output (fmt does the assembling), line-at-a-time reading, closing a channel.