(guile.info.gz) define* Reference
Info Catalog
(guile.info.gz) lambda* Reference
(guile.info.gz) Optional Arguments
23.2.4 define* Reference
------------------------
Just like `define' has a shorthand notation for defining procedures
( Lambda Alternatives), `define*' is provided as an abbreviation
of the combination of `define' and `lambda*'.
`define*-public' is the `lambda*' version of `define-public';
`defmacro*' and `defmacro*-public' exist for defining macros with the
improved argument list handling possibilities. The `-public' versions
not only define the procedures/macros, but also export them from the
current module.
-- library syntax: define* formals body
-- library syntax: define*-public formals body
`define*' and `define*-public' support optional arguments with a
similar syntax to `lambda*'. They also support arbitrary-depth
currying, just like Guile's define. Some examples:
(define* (x y #:optional a (z 3) #:key w . u)
(display (list y z u)))
defines a procedure `x' with a fixed argument Y, an optional
argument A, another optional argument Z with default value 3, a
keyword argument W, and a rest argument U.
(define-public* ((foo #:optional bar) #:optional baz) '())
This illustrates currying. A procedure `foo' is defined, which,
when called with an optional argument BAR, returns a procedure
that takes an optional argument BAZ.
Of course, `define*[-public]' also supports `#:rest' and
`#:allow-other-keys' in the same way as `lambda*'.
-- library syntax: defmacro* name formals body
-- library syntax: defmacro*-public name formals body
These are just like `defmacro' and `defmacro-public' except that
they take `lambda*'-style extended parameter lists, where
`#:optional', `#:key', `#:allow-other-keys' and `#:rest' are
allowed with the usual semantics. Here is an example of a macro
with an optional argument:
(defmacro* transmorgify (a #:optional b)
(a 1))
Info Catalog
(guile.info.gz) lambda* Reference
(guile.info.gz) Optional Arguments
automatically generated byinfo2html