@Env
The type of env, which reads, writes, iterates, spreads, and
destructures like a Dict of variable names and values.
Assigning nil unsets a variable. Reading a name that is not set raises; use
get for a default instead.
Inherits from: std.Index[Str, Str], std.Assign[Str, Str | nil], std.Spread[Str, Str], std.Unpack[Str, Str], std.BaseIterable[Tuple[Str, Str]]
Methods
(call)[R] vars body -> R
Calls body with overrides from a dict in place, restoring them when it
returns.
Parameters
| Name | Type | Description |
|---|---|---|
vars |
Dict[Str | Sym, Str | :INHERIT: | nil] |
The overrides, as for keyword arguments. |
body |
(() -> R) |
The block to call. |
(call)[R] body ...vars -> R
Calls body with the variables given as keyword arguments in place,
restoring them when it returns.
A nil value unsets a variable, and :INHERIT: captures the variable's
current value in the calling strand.
Parameters
| Name | Type | Description |
|---|---|---|
body |
(() -> R) |
The block to call. |
...vars |
Overrides by variable name. |
Example
get[D] name … -> (Str | D | nil)
Reads a variable, returning nil rather than raising when it is unset.
Parameters
| Name | Type | Description |
|---|---|---|
name |
Str |
The variable name. |
:default? |
D |
The value to return when the variable is unset. |
:else? |
(() -> D) |
A block whose result to return when the variable is unset and there is no
default. |