Macros
Macros provide a facility for extending the base syntax of GOO. The
design is based on quasiquote code templates and a simple list pattern
matching facility. Macros are currently unhygienic, and users are
required to use gensym to avoid name collisions.
QUASIQUOTE | (QUASIQUOTE ,@qq-forms) | S |
| QUOTE with selective evaluation using UNQUOTE and
SPLICING-UNQUOTE (cf. Lisp and Scheme's QUASIQUOTE),
abbreviated "`". | |
UNQUOTE | (UNQUOTE ,form) | S |
| evaluates ,form in the midst of a QUASIQUOTE
expression, abbreviated ",". | |
SPLICING-UNQUOTE | (SPLICING-UNQUOTE ,form) | S |
| evaluates ,form in the midst of a QUASIQUOTE
expression and splices it in, abbreviated ",@". | |
MATCH | (MATCH ,exp (,pat ,val) ...) | S |
| evaluates ,val corresponding to first ,pat
matching ,exp. The pattern is much the same as QUASIQUOTE
and can contain either UNQUOTE'd variables
or UNQUOTE-SPLICING variables. For example,
(MATCH '(1 2) ((,a ,b) (lst a b))) $ --> $ (1 2)
(MATCH '(1 2) ((,a ,@b) (lst a b))) $ --> $ (1 (2))
| |
DS | (DS ,name (,pattern) ,@body) | S |
| defines a macro matching pattern ,pattern and expanding according to
,@body. The pattern matching occurs as in MIF and
makes available pattern variables during the evaluation
of (SEQ ,@body). For example,
(DS unless (,test ,@body)
`(if (not ,test) (seq ,@body)))
defines the when macro in GOO. | |
|
where
pattern | == (,@qq-forms) | L |
|
CT | (CT ,@body) | S |
| evaluates (SEQ ,@body) at compile-time allowing a user to make
available computations for the purpose of macro-expansion. | |
CT-ALSO | (CT-ALSO ,@body) | S |
| equivalent to CT, but also includes a copy of
,@body in compiled
images. Similar to (eval-when (:compile-toplevel :execute) ...)
in Common LISP. The return value of CT-ALSO is undefined. | |
MACRO-EXPAND | (MACRO-EXPAND ,form) | S |
| recursively expands macros in expression ,form. | |
|