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), wherebandaare applicatives, as follows. Each call tomake-keyed-dynamic-variablereturns differentbanda.
bis 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.ais an applicative that takes zero arguments. If the call toaoccurs within the dynamic extent of a call tob, thenareturns the value of the first argument passed tobin the smallest enclosing dynamic extent of a call tob. If the call toais 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), wherebandaare applicatives, as follows. Each call tomake-keyed-static-variablereturns differentbanda.
bis 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.ais an applicative that takes zero arguments. If the dynamic environmenteof 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 tobin the first such environment encountered by a depth-first traversal of the improper ancestors ofe. Ifehas no improper ancestors constructed viab, an error is signaled.