A vanilla implementation of Macro by Example (Eugene Kohlbecker,
R4RS) by Dorai Sitaram, (dorai @ cs.rice.edu) using
define-syntaxMacro-by-Example macros cheaply.
defmacronatively supported (most implementations)
These macros are not referentially transparent
(see Macros in Revised(4) Scheme). Lexically scoped macros
letrec-syntax) are not supported.
In any case, the problem
of referential transparency gains poignancy only when
letrec-syntax are used. So you will not be courting
large-scale disaster unless you’re using system-function names as local
variables with unintuitive bindings that the macro can’t use. However,
if you must have the full r4rs macro functionality, look to the
more featureful (but also more expensive) versions of syntax-rules
available in slib Macros That Work, Syntactic Closures, and
The keyword is an identifier, and the transformer-spec
should be an instance of
The top-level syntactic environment is extended by binding the keyword to the specified transformer.
(define-syntax let* (syntax-rules () ((let* () body1 body2 ...) (let () body1 body2 ...)) ((let* ((name1 val1) (name2 val2) ...) body1 body2 ...) (let ((name1 val1)) (let* (( name2 val2) ...) body1 body2 ...)))))
literals is a list of identifiers, and each syntax-rule should be of the form
where the pattern and template are as in the grammar above.
An instance of
syntax-rules produces a new macro transformer by
specifying a sequence of hygienic rewrite rules. A use of a macro whose
keyword is associated with a transformer specified by
syntax-rules is matched against the patterns contained in the
syntax-rules, beginning with the leftmost syntax-rule.
When a match is found, the macro use is trancribed hygienically
according to the template.
Each pattern begins with the keyword for the macro. This keyword is not involved in the matching and is not considered a pattern variable or literal identifier.