M::
Factor handbook > The language > Lexical variables

Prev:::
Next:MEMO::


Vocabulary
locals

Syntax
M:: class generic ( vars... -- outputs... ) body... ;


Word description
Defines a new method on generic for class with named inputs. The method binds its input values to lexical variables from left to right, then executes the body with those bindings in scope.

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

Notes
The names of the outputs do not affect the word's behavior. However, the compiler verifies that the stack effect accurately represents the number of outputs as with M: definitions.

Examples
See Examples of lexical variables.

Definition