Document (std os), numeric/si and Ctrl-C and SIGTERM
A module page and a standard library entry for (std os), numeric/si and a section on signals in writing programs, and the span conversions in the language basics.
This commit is contained in:
parent
1a2a43bf5a
commit
f07cd79e3e
4 changed files with 96 additions and 5 deletions
|
|
@ -142,6 +142,15 @@ For more details, see @link["modules/std/inbox.html"]{@code{(std inbox)}}.
|
|||
Bridges for .NET APIs that want something a Bjolang function or value is not. A Bjolang function is a @code{Func} whose @code{void} return is the unit value; @code{as-delegate} and @code{as-delegate/type} wrap a function in another .NET delegate type such as @code{Action}, @code{EventHandler} or a library's custom delegate. @code{add-event-handler!} and @code{remove-event-handler!} subscribe a Bjolang function to a .NET object's event by name. @code{clr-default} produces .NET's @code{default(T)} (such as @code{null} for a reference type or a @code{Nullable<T>}) when a .NET call requires one.
|
||||
For more details, see @link["modules/std/interop.html"]{@code{(std interop)}}.
|
||||
|
||||
@subsection{std/os}
|
||||
|
||||
The operating system the program runs on: @code{windows?}, @code{linux?}, @code{macos?}, @code{freebsd?} and the others, @code{os-platform?} by name, and @code{windows-version-at-least?} and the other version checks, with the minor version, the build and the revision as keywords. Each is .NET's @code{OperatingSystem} method, called where it is written. .NET's core library is built for one system, so the method returns a constant there, and the JIT removes the branch that cannot run. A program is built once and chooses when it runs, and code for one system can be in a module of its own: a module that nothing calls does nothing.
|
||||
|
||||
It also has the facts about the machine and the process: @code{os-description}, @code{os-version}, @code{os-architecture}, @code{processor-count}, @code{available-memory}, @code{machine-name}, @code{user-name}, @code{process-id} and others. And the user's folders: @code{home-directory}, @code{config-directory}, @code{data-directory}, @code{cache-directory}, @code{documents-directory}, @code{desktop-directory} and @code{temp-directory}, which follow the XDG variables on Linux and each system's own place elsewhere, and @code{make-temp-directory} for a new directory that only its owner can enter.
|
||||
|
||||
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/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.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue