Next: , Previous: , Up: Filters   [Contents][Index]

7.6.3 Writing to Streams

Similarly, unlike normal Unix file descriptors, write-only poke streams are also buffered and can be accesses randomly:

var stdout = open ("<stdout>");

We can write to the output stream by mapping as usual:

byte @ stdout : 28#B = 0xff;

The mapping operation above writes 27 null bytes, i.e. it fills until reaching the requested offset in the output stream. Then it writes the byte 0xff at offset 28 bytes. If we then write to one of the buffered bytes:

byte @ stdout : 27#B = 0xab;

This results in updating the byte that will be written right before the 0xff once the output stream is flushed.

Again, we cannot buffer ad-infinitum: we would exhaust all available output. Therefore, XXX