← index

[IO]Stdinabstract

inherits Object

The process's standard input.

Reads park the task rather than blocking the scheduler, so a program can serve sockets while it waits on a line. The stream is created on the first read and reused: it buffers, so there can only be one. readLine / eachLine: / readAll are the everyday surface; stream and byteStream expose the stream itself.

extended at core/06-io.qn:11

[IO]Stdin is a class rather than a constant like the two above: opening stdin parks on the scheduler, and the prelude also runs under qn benchmark, which has none. The stream is created on the first read and reused forever after — it buffers, so there can only be one. These delegators just forward to it; the reads themselves park, so a program can serve sockets while it waits on a line.

Class methods

byteStream

The one shared ByteStream over standard input, created on first use.

native

close

Close the shared stdin stream; a later read raises an IoError of kind #closed.

core/06-io.qn:27

closed?

Whether the shared stdin stream has been closed with close (reaching end of input does not close it).

core/06-io.qn:24

eachLine:Block

Every remaining line, one block call each. The idiom for a filter program.

core/06-io.qn:17

readAll

Everything remaining, as one String.

core/06-io.qn:20

readLine

The next line, without its terminator; nil at end of input.

core/06-io.qn:14

stream

The one shared StringStream over standard input, created on first use. Asking for the byte view after the text view (or vice versa) is an error: a stream buffers, so two views would each hold bytes the other never sees.

native