Document (std stream), port->stream and run/stream
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
6634469ae8
commit
5e07283404
4 changed files with 71 additions and 5 deletions
|
|
@ -69,7 +69,7 @@ For more details, see @link["modules/std/url.html"]{@code{(std url)}}.
|
|||
|
||||
@subsection{std/run}
|
||||
|
||||
The @code{std/run} module provides a way to run external programs. A form is one thing to run, written as a quoted literal, like @code{'(cat "hej.txt")}. You can connect programs in a pipe with @code{'(pipe (cat "a") (wc -l))}, and redirect input and output to files. Redirections can nest, and you can even splice computed arguments or write stages in Bjolang.
|
||||
The @code{std/run} module provides a way to run external programs. A form is one thing to run, written as a quoted literal, like @code{'(cat "hej.txt")}. You can connect programs in a pipe with @code{'(pipe (cat "a") (wc -l))}, and redirect input and output to files. Redirections can nest, and you can even splice computed arguments or write stages in Bjolang. @code{run/stream} gives a program's output as a @code{Stream}: each loop over it runs the program, and the program is killed however the loop ends.
|
||||
For more details, see @link["modules/std/run.html"]{@code{(std run)}}.
|
||||
|
||||
@subsection{std/random}
|
||||
|
|
@ -151,9 +151,14 @@ It also has the facts about the machine and the process: @code{os-description},
|
|||
And the signals, as union cases such as @code{Interrupt}, @code{Terminate} and @code{Hangup}. @code{with-signal-cancel} is a scope that the first of its signals cancels, so that a program cleans up on Ctrl-C or SIGTERM; a second signal ends the program at once. @code{on-signal} calls a function for each signal that comes, until the scope ends. @code{signal-subscribe} gives signals as values from the event @code{signal-recv}, and signals of one kind that wait are merged into one.
|
||||
For more details, see @link["modules/std/os.html"]{@code{(std os)}}.
|
||||
|
||||
@subsection{std/stream}
|
||||
|
||||
Loops over values that suspending work produces. A @code{Stream} is a driver, @code{(:for x s)}, whose producer is a bjoroutine that hands each value to the loop with @code{emit!}. Each loop over it starts the producer, which computes a value only when the loop asks for it, and stops it however the loop ends. @code{make-stream} makes one from a bjoroutine, and @code{{streaming expr clause ...}} from loop clauses. @code{in-chan} reads a channel that something else fills, until an event such as the producer's @code{promise-join} commits.
|
||||
For more details, see @link["modules/std/stream.html"]{@code{(std stream)}}.
|
||||
|
||||
@subsection{std/ports and std/net}
|
||||
|
||||
@code{(std ports)} reads and writes bytes on the prelude's ports. The byte reads @code{read-some-evt}, @code{read-bytes-evt} and @code{eof-evt} are CML events: a read that loses its @code{choose} takes nothing, so a read can race a timeout. @code{read-line} and @code{read-bytes} can be used on the same port. The module also drains ports into lists and vecs, streams them as a @code{Seq} or a channel, and has @code{byte-pipe}, a pair of ports with no file and no network, for tests. @code{(std net)} gives a TCP connection as a pair of these ports, so a protocol written for ports also runs over TCP. @code{accept-evt} is an event too: a branch that loses accepts nothing.
|
||||
@code{(std ports)} reads and writes bytes on the prelude's ports. The byte reads @code{read-some-evt}, @code{read-bytes-evt} and @code{eof-evt} are CML events: a read that loses its @code{choose} takes nothing, so a read can race a timeout. @code{read-line} and @code{read-bytes} can be used on the same port. The module also drains ports into lists and vecs, streams them as a @code{Seq} or, for a bjoroutine, as a @code{Stream} with @code{port->stream}, and has @code{byte-pipe}, a pair of ports with no file and no network, for tests. @code{(std net)} gives a TCP connection as a pair of these ports, so a protocol written for ports also runs over TCP. @code{accept-evt} is an event too: a branch that loses accepts nothing.
|
||||
For more details, see @link["modules/std/ports.html"]{@code{(std ports)}} and @link["modules/std/net.html"]{@code{(std net)}}.
|
||||
|
||||
@subsection{std/test and std/simpletest}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue