:>
Factor handbook > The language > Lexical variables

Prev:[let
Next:[|


Vocabulary
locals

Syntax
:> var :> var! :> ( var-1 var-2 ... )


Word description
Binds one or more new lexical variables. In the :> var form, the value on the top of the datastack is bound to a new lexical variable named var and is scoped to the enclosing quotation, [let form, or :: definition.

The :> ( var-1 ... ) form binds multiple variables to the top values of the datastack in right to left order, with the last variable bound to the top of the datastack. These two snippets have the same effect:
:> c :> b :> a

:> ( a b c )


If any var name is followed by an exclamation point (!), that new variable is mutable. See Mutable lexical variables for more information.

Notes
This syntax can only be used inside a lexical scope established by a :: definition, [let form, or [| quotation. Normal quotations have their own lexical scope only if they are inside an outer scope. Definition forms such as : do not establish a lexical scope by themselves unless documented otherwise, nor is there a lexical scope available at the top level of source files or in the listener. [let can be used to create a lexical scope where one is not otherwise available.

Examples
See Examples of lexical variables.

See also
[let

Definition