- (define-compiler-syntax NAME)syntax
- (define-compiler-syntax NAME TRANSFORMER)syntax
Defines what is usually called a compiler macro in Lisp: NAME should be the name of a globally or locally bound procedure. Any direct call to this procedure will be transformed before compilation, which allows arbitrary rewritings of function calls.
TRANSFORMER can be a syntax-rules expression or a transformer procedure (as returned by er-macro-transformer or ir-macro-transformer). Returning the original form in an explicit/implicit-renaming macro or simply "falling trough" all patterns in a syntax-rules form will keep the original expression and compile it normally.
In the interpreter this form does nothing and returns an unspecified value.
Compiler-syntax is always local to the current compilation unit and can not be exported. Compiler-syntax defined inside a module is not visible outside of that module.
define-compiler-syntax should only be used at top-level. Local compiler-syntax can be defined with let-compiler-syntax.
(define-compiler-syntax + (syntax-rules () ((_) 1) ((_ x 0) x) ) )
If no transformer is given, then (define-compiler-syntax NAME) removes any compiler-syntax definitions for NAME.