<\body> Macros can be used to define new tags and to build procedural abstractions in style files. Older versions of used to make a distinction between macros (all children accessible) and functions (no accessible child). In modern there are only macros: the accessibility of children is determined heuristically and can be controlled with . <\explain> >|var-n|body> <|explain> This primitive returns a macro (the analogue of a >-expression) with arguments, named after the literal strings until . New tags are defined by storing macros in the environment. Most of the time, macros are stored without scope with , but it is sometimes useful to redefine a tag locally within the scope of a . For example, itemized and enumerated environment redefine locally. <\example> Definition of the tag <\tm-fragment> >>>> Storing a in the environment defines a tag whose arity is fixed to the number of arguments taken by the macro. <\explain> >|index-n> <|explain> 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 (literal string). Of course, this argument must be defined by a containing the tag. This tag is similar to , but differs in important ways: <\itemize> The argument namespace is distinct from the environment, and will generally evaluate to different values (although you should not rely on this). The value of retains the position of the macro argument in the document tree, that makes it possible to edit the arguments of a macro-defined tag while it is active. When more than one arguments are specified, >|index-n> expands to a subtree of the argument . The value of the named argument must be a compound tree (not a string). The operands until must all evaluate to positive integers and give the path to the subtree of the macro argument. <\explain> <|explain> This primitive returns a macro (the analogue of a >-expression) capable of taking any number of arguments. The arguments are stored in the macro variable with name (a literal string) during the evaluation of the . The -th individual argument can then be accessed using . <\explain> <|explain> This primitive evaluates to a tree whose root is labeled by and whose children are the result of applying the macro to the children of the macro argument with name . By default, the macro is applied to all children. If has been specified, then we rather start at the -th child of , where is the result of evaluating . If has been specified too, then we stop at the -th child of (the -th child not being included), where is the result of evaluating . In this last case, the arity of the returned tree is therefore . Stated otherwise, applies to all subtrees of the macro argument (or a range of subtrees if and are specified) and collect the result in a tree with label . In addition, the second argument to gives its position of the first argument in the expansion of . The is analogue to the function . Since use labeled trees, the label of the mapping list must also be specified. <\example> Comma-separated lists. The tag has any arity (though it does not make much sense with arity zero) and typeset its operands interspersed with commas. <\tm-fragment> >>> >>>> <\explain> <|explain> This primitive evaluates to the tree with the same label as the expansion of the argument and whose subtrees are the result of the evaluation of the subtrees of the expansion of . <\explain> >|arg-n> <|explain> 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 to the arguments until . The primitive is useful in call-back and lambda programming idioms, where a is given a macro as an operand, which it may later apply under certain conditions or with operands which are not known to the client code. Actually, in the current implementation, 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. <\example> Lambda programming with macros. In the code below, expects a macro and a tuple on input and returns a tuple containing the elements of for which evaluates to . <\tm-fragment> >|0>||||0>>||0>>|>>|||1|>>>>>>>>>> As an application, we may define a macro , which expects to be a tuple containing integers, and which returns the tuple of integers in which are divisible by 2. <\tm-fragment> |2>|0>>|>>>> <\explain> >|prop-n|val-n> properties of a tag> <|explain> The arity and children accessibility of tags defined by macros are determined heuristically by default. The primitive overrides this default for the environment variable (usually a macro) with name . The currently supported property-value pairs are: <\description-dash> )>Sets the arity to the given fixed value (literal integer). Make it impossible to deactivate the tag with normal editor actions. Inaccessible children become effectively uneditable. Make it impossible to position the caret within the tag when it is active, so children can only be edited when the tag is inactive. <\explain> <|explain> Returns the label of the tree obtained when evaluating . <\explain> <|explain> Returns the label of the tree obtained when evaluating . <\initial> <\collection>