Dynamic Environment
Atomo has a dynamic system similar to Scheme's parameterize
and Common Lisp's defvar
.
The usual convention of using *earmuffs*
for dynamic variable names is fine, but it's not really necessary as it's harder for them to collide with normal variables (accessing is either explicit or lexical, and updating is explicit).
top define: name as: root → root
Creates a new dynamic variable called name
, defining an accessor in top
. The accessor simply performs name _?
.
If the dynamic variable already exists, it is replaced.
name _? → any
Retrieves the binding for name
from the dynamic environment.
Normally you won't need to do this, since define:as:
defines an accessor for you, so you can just say the name.
name =! value → value
Updates the most recent binding for name
as value
. This cannot replace the root value.
with: name as: binding do: action → any | action is-a?: Block
Calls action
with name
bound as binding
.