]> Repositorios git - scryer-prolog.git/commit
ENHANCED: open/4 to allow opening a stream by specifying stream(S).
authorMarkus Triska <[email protected]>
Thu, 4 Nov 2021 17:28:05 +0000 (18:28 +0100)
committerMarkus Triska <[email protected]>
Thu, 4 Nov 2021 17:33:40 +0000 (18:33 +0100)
commitafcd44deaad49a8e77094d7dac6b377e3f263f73
tree86f03be7a8997d71074c20ec1a7c5e508bc77835
parent67ef5fe8e6ed6930fc6e761156c5c55c6dea2b5c
ENHANCED: open/4 to allow opening a stream by specifying stream(S).

This allows switching standard output to binary, using for example:

  ?- current_output(S0), open(stream(S0), write, S, [type(binary)]).

format/3 can then be used to write binary data to S. This is needed
for example when piping binary data to other programs.

This addresses #614, please read the discussion for more information.

The current implementation is very preliminary: Specifically, it works
by destructively modifiying the parameters of the underlying stream,
making it no longer usable in its original mode. Currently, if the
type of standard output is set to binary, then the toplevel no longer
works. Therefore, after writing binary output to standard output,
the program should either halt, or set the stream type back to text.
src/clause_types.rs
src/lib/builtins.pl
src/machine/system_calls.rs