Skip to content

environment

Turtle Kitty edited this page Aug 7, 2015 · 2 revisions

env

Environments map names to values.
Whenever you bind a name (def name value) or assign one (set! name value), you are changing the environment.
Functions and operators close over the variables in their lexical parent environments.

The current environment can be accessed with the operator env.

methods

(x.get name), (x.has? name), (x.del! name), x.to-bool, x.pairs -> see record.

x.type -> env

x.mama -> returns the environment's Sexy mama.

(x.def! name value) -> bind a new name to a value in the environment

(x.set! name value) -> assign a new value to an existing name in the environment

(x.lookup name) -> looks up a name in the current environment. If not found, lookup searches all mama environments recursively.

(x.extend names values) -> creates a new environment, with x as mama, and binds the list of names to their respective values.

(x.eval S-expression) -> evaluates the expression in the environment x

(x.expand S-expression) -> macroexpands the given expression in the environment x

Clone this wiki locally