Previous: makers intro, Up: makers [Index]
The following bindings are exported by the (vicare
language-extensions makers)
library.
Define a new maker macro. name-spec has one of the forms:
name-identifier (name-identifier positional-arg ...)
where name-identifier is the name of the defined macro and each positional-arg is an identifier, name of a mandatory positional argument for the macro.
maker-sexp has one of the forms:
maker-expr0 (maker-expr0 maker-expr ...)
where each maker-expr is a macro keyword or an expression
evaluated in the lexical context of the define-maker
macro use;
the expressions are evaluated every time the maker is used.
keywords-defaults-options defines optional arguments selected with an auxiliary syntax and a value; it has the form:
(clause-spec ...)
where each clause-spec has the form:
(auxiliary-syntax default-expr) (auxiliary-syntax default-expr option ...)
where each auxiliary-syntax is an identifier and
default-expr is an expression representing the default value for
the argument; the expressions are all evaluated in the lexical context
of the define-maker
macro use, the expressions are evaluated
every time the maker is used.
Notice that the auxiliary-syntax identifiers are matched against
the values in the macro use by comparing the syntax objects with
free-identifier=?
.
Each of the option forms can be one among:
(mandatory) (optional) (with identifier ...) (without identifier ...)
where the first two specify if the current clause is mandatory or
optional; the with
option selects a list of clauses that must be
present when the current clause is used; the without
option
selects a list of clauses that must not be present when the current
clause is used. Each clause can be used at most once;
mandatory
cannot appear along with optional
.
When the new macro is used without optional auxiliary syntaxes, it is expanded to:
;; single maker expression, no positional arguments (maker-expr-result) ;; single maker expression, positional arguments (maker-expr-result positional-arg0 positional-arg ...) ;; multiple maker expressions, no positional arguments (maker-expr-result0 maker-expr-result ...) ;; multiple maker expressions, positional arguments (maker-expr-result0 maker-expr-result ... positional-arg0 positional-arg ...)
When the new macro is defined with optional auxiliary syntaxes, the expressions in the given syntax clauses, or the default expressions, are appended to the output form in the same order as the corresponding syntaxes in keywords-defaults-options.
It is an error if the generated maker is invoked with a clause used multiple times.
When the clause of a generated maker is used with multiple values: the
values are enclosed in a list
form and the result is used as
argument for the maker expression; for example:
(import (vicare) (prefix (vicare language-extensions makers) mk.)) (define-syntax alpha:) (mk.define-maker doit vector ((alpha: (list 1 2 3)))) (doit) → (vector (list 1 2 3)) (doit (alpha: 10 20 30)) → (vector (list 10 20 30))
Previous: makers intro, Up: makers [Index]