1 Meta Definitions and Expressions
declaration | |||
| |||
| |||
declaration | |||
Alternatively, meta can have a single nestable_body in a group, in which case it is equivalent to a block with the single nestable_body.
See also the meta import modifier.
> meta:
syntax_class Arithmetic
> expr.macro 'right_operand $(exp :: Arithmetic)':
exp.y
> right_operand 1 + 2
2
x+1
> expr.macro 'add1_statically $(n :: Int)':
'#%literal $(add1(Syntax.unwrap(n)))'
> add1_statically 13
14
definition | |||
|
The result of the body block might be a macro transformer that is triggered by a use of id_or_op_name, or it might be some other kind of value that is accessed with syntax_meta.value.
For example, forms like expr.macro, bind.macro, and annot.macro expand to meta.bridge. In those cases, the generated body block produces an expression transformer, binding transformer, or annotation transformer. Some forms that expand to meta.bridge enrich the id_or_op_name with a scope for a space of bindings, which enables overloading a id_or_op_name for different contexts like expressions versus bindings. For example, annot.macro enriches its id_or_op_name with a scope for annotation operators.