← index

[OS]Envabstract

inherits Object

READ-ONLY access to the process environment. Mutation is deliberately absent: the C environment is process-global state that other threads (workers, the blocking I/O pool) may be reading concurrently, so setting variables would be a soundness hazard. Listings are sorted by name, and entries that are not valid UTF-8 are skipped rather than mangled.

extended at core/12-os.qn:4

Conveniences over the native [OS] namespace (src/runtime/os.rs). Kept in Quoin because they only compose the native primitives — no reason to spend a native method (or a block call from Rust) on either.

Class methods

asMap

The whole environment as a Map, sorted by name -- and, via Map, the way to get the Iterate combinators (select:, collect:, ...) over the environment (a namespace class has no instances to mix into).

native

at:String

The value of the variable, or nil when unset. An empty value is '', not nil -- 'FOO=' is set. A name or value that is not valid UTF-8 reads as nil.

([OS]Env.at:'PATH').defined?    "* -> true

native

at:String ifAbsent:Block

The value of name, or the block's value when unset. nil is only ever "unset": a variable with an empty value reads as '', so the fallback does not fire for FOO=.

[OS]Env.at:'QN_SURELY_UNSET' ifAbsent:{ 'fallback' }    "* -> fallback

core/12-os.qn:12

contains?:String

Whether the variable is set at all, empty value included.

[OS]Env.contains?:'PATH'    "* -> true

native

count

How many environment variables are set.

core/12-os.qn:23

each:Block

Iterate the environment as KeyValuePairs, sorted by name. .asMap is the general door — it carries the whole Iterate mixin (select:, collect:, detect:, …), which a namespace class cannot mix in for itself.

core/12-os.qn:20

keys

Every variable name, as a List of Strings sorted by name.

native