6.57. kink/io/BIN_OUTPUT¶
6.57.1. BIN_OUTPUT.new¶
`new` makes an `output` which builds a `bin`.
The result `output` also provides `bin` method. It returns a `bin` val which joins bytes passed to `write` method.
flush
`flush` method does nothing. It just tail-calls $success, if the `output` is not closed.
close
If the `output` is closed, `write` and `flush` methods cause an IO error, like other `output` implementations based on system resources.
Example
:BIN_OUTPUT.require_from('kink/io/')
:BIN.require_from('kink/')
:CONTROL.require_from('kink/')
:make_bin <- {
CONTROL.with_finally{(:finally)
:Out = BIN_OUTPUT.new
finally{ Out.close }
Out.write(BIN.of(1 2 3))
Out.write(BIN.of(4))
Out.bin
}
}
stdout.print_line(make_bin.repr) # => (bin 0x01 0x02 0x03 0x04)