-
Notifications
You must be signed in to change notification settings - Fork 4
operator
An operator is a function that runs at compile time.
It operates on source code rather than values.
Operators can be used to create new syntax.
New operators are created by the macro operator.
Many core operators - such as when, cond, case, let, for, and while - are defined in terms of more primitive ones.
(macro when (pred)
%(if $pred
(seq @rest)
null))
Operators, like functions...
...close over their current lexical environment
...have an implied (seq ...) for multiple bodies
...are variadic and can accept optional keyword parameters
Operators are just procedures that run at compile time, so they respond to the same messages as procedures. They can be used at runtime via the magic of apply, but their arguments must be quoted, and their output will be unevaluated unless piped into env.eval.