Previous: lambda* Reference, Up: Optional Arguments
Just like define has a shorthand notation for defining procedures
(see 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.
define*anddefine*-publicsupport optional arguments with a similar syntax tolambda*. 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
xwith 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
foois defined, which, when called with an optional argument bar, returns a procedure that takes an optional argument baz.Of course,
define*[-public]also supports#:restand#:allow-other-keysin the same way aslambda*.
These are just like
defmacroanddefmacro-publicexcept that they takelambda*-style extended parameter lists, where#:optional,#:key,#:allow-other-keysand#:restare allowed with the usual semantics. Here is an example of a macro with an optional argument:(defmacro* transmorgify (a #:optional b) (a 1))