Macro primitives |
Macros can be used to define new tags and to build abstraction with procedures in style files.
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
This primitives returns a macro (the TeXmacs analogue of a λ-expression) with n arguments, named after the literal strings var-1 until var-n.
New tags are defined by storing macros in the environment. Most of
the time, macros are stored without scope with
|
This primitive is used to retrieve the arguments of a macro within
its body. For instance, expands the content of the macro argument
with name arg (literal string). Of
course, this argument must be defined by a
This tag is similar to
This primitive evaluates to a tree whose root is labeled by root and whose children are the result of applying the macro foo to the children of the macro argument with name var.
By default, the macro foo is applied to all children. If first has been specified, then we rather start at the i-th child of var, where i is the result of evaluating first. If last has been specified to, then we stop at the j-th child of var (the j-th child not being included), where j is the result of evaluating last. In this last case, the arity of the returned tree is therefore j - i.
Stated otherwise,
The
The
|
This primitive evaluates to the tree with the same label as the expansion of the argument var and whose subtrees are the result of the evaluation of the subtrees of the expansion of var.
To do: How is that practically useful? |
This primitive is useful to expand macros which are the result of a
computation: it applies the macro which is the result of the
evaluation of foo to the arguments arg-1 until arg-n.
The
Actually, in the current implementation, foo may either evaluate to a macro or to a literal string which gives the name of a macro. However, we discourage users to rely on the second case.
In the code below, expects a macro pred
and a tuple t on input and
returns a tuple containing the elements of t
for which pred evaluates to true.
As an application, we may define a macro , which expects t to be a tuple containing integers, and which returns the tuple of integers in t which are divisible by 2.
|
The arity and children accessibility of tags defined by macros are
determined heuristically by default. The