Kawa supports most of the syntax-case feature.
Syntax: defmacro name lambda-list form ...
Defines an old-style macro a la Common Lisp, and installs
(lambdaas the expansion function forlambda-listform...)name. When the translator sees an application ofname, the expansion function is called with the rest of the application as the actual arguments. The resulting object must be a Scheme source form that is futher processed (it may be repeatedly macro-expanded).If you define a macro with
defmacro, you (currently) cannot use the macro in the same compilation as the definition. This restriction does not apply to macros defined usingsyntax-rules.
Returns a new (interned) symbol each time it is called. The symbol names are implementation-dependent. (This is not directly macro-related, but is often used in conjunction with
defmacroto get a fresh unique identifier.)
Syntax: cond-expand cond-expand-clause* [(else command-or-definition*)]
cond-expand-clause::=(feature-requirementcommand-or-definition*)
feature-requirement::=feature-identifier
|(andfeature-requirement*)
|(orfeature-requirement*)
|(notfeature-requirement)
feature-identifier::= a symbol which is the name or alias of a SRFI
The
cond-expandform tests for the existence of features at macro-expansion time. It either expands into the body of one of its clauses or signals an error during syntactic processing.cond-expandexpands into the body of the first clause whose feature requirement is currently satisfied; theelseclause, if present, is selected if none of the previous clauses is selected.A feature requirement has an obvious interpretation as a logical formula, where the
feature-identifiervariables have meaning true if the feature corresponding to the feature identifier, as specified in the SRFI registry, is in effect at the location of thecond-expandform, and false otherwise. A feature requirement is satisfied if its formula is true under this interpretation.Examples:
(cond-expand ((and srfi-1 srfi-10) (write 1)) ((or srfi-1 srfi-10) (write 2)) (else))(cond-expand (command-line (define (program-name) (car (argv)))))The second example assumes that
command-lineis an alias for some feature which gives access to command line arguments. Note that an error will be signaled at macro-expansion time if this feature is not present.