Section "stream"

The Dogelog player currently does provide a stream abstraction. It also keeps a global state, for the current input and output streams. By now, we only support text streams and no byte streams. The output abstraction is a bounded buffer that is flushed when it reaches a hard-wired limit or when the flush_output/2 built-in is explicitly called.

As a further restriction we currently do not support stream aliases. There is currently only a predicate open/3, the stream result being a reference data type. It is up to the application to manage its streams. The Prolog system will not keep a table of some sort and therefore simpli-fy garbage collection by the underlying host programming language.

The following stream built-ins are provided:

open(P, M, S): [ISO 8.11.5.4]
The built-in succeeds in S with a new stream for the path P and the mode M. The available open modes are as follows. Depending on path and target platform not all open modes might be supported:

read: Open the path for reading.
write: Open the path for writing, truncate when it already exists.
append: Open the path for writing, seek to end when it already exists.
open(P, M, S, O): [ISO 8.11.5.4]
The built-in succeeds in S with a new stream for the path P and the mode M and open options O. The available open options are as follows. Depending on path, open mode and target platform not all open options might be supported.

type(T): The type T of the stream S, ‘binary’ or ‘text’.
method(M): Override the request method by M.
headers(P): Add the request headers P.
body(B): Send the request body B.
body(B, O): Send the request body B with write options O.
uri(U): Return in U the path after redirects.
status(S): Return in S the response status.
fields(F): Return in F the response headers.
close(S): [ISO 8.11.6]
The built-in succeeds. As a side effect, the stream S is closed.

Kommentare