<< Prev | - Up - | Next >> |
Macro
ModulemacroExpand
{Macro.macroExpand
+X
+Env
?Y
}
X
is a term representing Oz code using Syntax Tree Format. This performs full macro expansion on X
with respect to macro environment Env
and returns Y
which is guaranteed to no longer contain any macro invocation. A macro environment maps macro names to expanders. Env
may also be unit
in which case the global macro environment is used which contains all the macros registered using Macro.defmacro
.
defmacro
{Macro.defmacro
+A
+F
}
A
should be an atom. A new global macro is defined which is invoked using atom A
and implemented using macro expander F
.
makeVar
makeNamedVar
{Macro.makeVar
?X
}
{Macro.makeNamedVar
+A
?X
}
This is very useful to create on the fly new representations of variables that are guaranteed not to conflict with those in user code. With Macro.makeNamedVar
, you supply an atom that provides the variable with a more meaningful name. This can be helpful for debugging. For example:
X = {Macro.makeNamedVar 'Tail'}
creates a new variable representation, guaranteed to be distinct from any other variable representation, and whose print name is Tail
.
sequenceToList
{Macro.sequenceToList
+X
?L
}
Converts the syntactic representation of a sequence to a list
listToSequence
{Macro.listToSequence
+L
?X
}
Converts a list to the syntactic representation of a sequence
<< Prev | - Up - | Next >> |