Lexical variables
Factor handbook » The language

Prev:Co-operative threads
Next:Dynamic variables


The locals vocabulary provides lexically scoped local variables. Full closure semantics, both downward and upward, are supported. Mutable variable bindings are also provided, supporting assignment to bindings in the current scope or in outer scopes.
Image Examples of lexical variables

Word definitions where the inputs are bound to lexical variables:
Image
::

Image
M::

Image
MEMO::

Image
MACRO::


Lexical scoping and binding forms:
Image
[let

Image
:>


Quotation literals where the inputs are bound to lexical variables:
Image
[|


Additional topics:
Image Lexical variables in literals
Image Mutable lexical variables
Image Lexical variables and fry
Image Limitations of lexical variables

Lexical variables complement Dynamic variables.