Evaluation control |
The
<assign|new-theorem|<macro|name|text|<quasi|<assign|<unquote|name>|<macro|body|<surround|<no-indent><strong|<unquote|text>.
>|<right-flush>|body>>>>>>
When calling <new-theorem|theorem|Theorem> in this example, we
first evaluate all
<assign|theorem|<macro|body|<surround|<no-indent><strong|Theorem. >|<right-flush>|body>>>
Next, this expression is evaluated, thereby defining a macro
It should be noticed that the TeXmacs conventions for evaluation are
slightly different then those from conventional functional languages
like
For instance, when TeXmacs calls a macro <macro|x1|⋯|xn|body> with arguments y1 until yn, the argument variables x1 until xn are bound to the unevaluated expressions y1 until yn, and the body is evaluated with these bindings. The evaluation of yi takes place each time we request for the argument xi. In particular, when applying the macro <macro|x|x and again x> to an expression y, the expression y is evaluated twice.
In
<assign|foo|<macro|x|<blah|x|x>>>
would correspond to a
(define-macro (foo x)
‘(let ((x (lambda () ,x)))
(blah (x) (x)))
Conversely, the
(define-macro (foo x) (blah x x))
(define (fun x) (blah x x))
admit the following analogues in TeXmacs:
<document|<assign|foo|<macro|x|<eval|<blah|<quote-arg|x>|<quote-arg|x>>>>>>
<document|<assign|fun|<macro|x|<with|x*|x|<blah|<quote-value|x*>|<quote-value|x*>>>>>>
Here the primitives