13 Keyed Variables
A keyed variable is a device that associates a non-symbolic key (in the form of an accessor applicative) with a value depending on the context in which lookup occurs. Kernel provides two types of keyed variables: dynamic & static. Keyed Dynamic Variables use the dynamic extent as context and Keyed Static Variables use the dynamic environment.
13.1 Keyed Dynamic Variables
A keyed dynamic variable is a device that associates a non-symbolic key (in the form of an accessor applicative) with a value depending on the dynamic extent in which lookup occurs.
Returns a list of the form
(b a)
, whereb
anda
are applicatives, as follows. Each call tomake-keyed-dynamic-variable
returns differentb
anda
.
b
is an applicative that takes two arguments, the second of which must be a combiner. It calls its second argument with no operands (nil operand tree) in a fresh empty environment, and returns the result.a
is an applicative that takes zero arguments. If the call toa
occurs within the dynamic extent of a call tob
, thena
returns the value of the first argument passed tob
in the smallest enclosing dynamic extent of a call tob
. If the call toa
is not within the dynamic extent of any call tob
, an error is signaled.
13.2 Keyed Static Variables
A keyed static variable is a device that binds data in an environment by a non-symbolic key, where the key is an accessor applicative.
Returns a list of the form
(b a)
, whereb
anda
are applicatives, as follows. Each call tomake-keyed-static-variable
returns differentb
anda
.
b
is an applicative that takes two arguments, the second of which must be an environment. It constructs and returns a child-environment of its second argument, with initially no local bindings.a
is an applicative that takes zero arguments. If the dynamic environmente
of the call to a has an improper ancestor that was constructed by a call tob
, then a returns the value of the first argument passed tob
in the first such environment encountered by a depth-first traversal of the improper ancestors ofe
. Ife
has no improper ancestors constructed viab
, an error is signaled.