* define-syntax-rule
@ 2011-09-02 9:43 Andy Wingo
2011-09-03 20:25 ` define-syntax-rule Ludovic Courtès
0 siblings, 1 reply; 3+ messages in thread
From: Andy Wingo @ 2011-09-02 9:43 UTC (permalink / raw)
To: guile-devel
I just added the following to api-macros.texi:
@subsubsection Shorthands
One often ends up writing simple one-clause @code{syntax-rules} macros.
There is a convenient shorthand for this idiom, in the form of
@code{define-syntax-rule}.
@deffn {Syntax} define-syntax-rule (keyword . pattern) [docstring] template
Define @var{keyword} as a new @code{syntax-rules} macro with one clause.
@end deffn
Cast into this form, our @code{when} example is significantly shorter:
@example
(define-syntax-rule (when c e ...)
(if c (begin e ...)))
@end example
Happy hacking,
Andy
--
http://wingolog.org/
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2011-09-04 10:11 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-09-02 9:43 define-syntax-rule Andy Wingo
2011-09-03 20:25 ` define-syntax-rule Ludovic Courtès
2011-09-04 10:11 ` define-syntax-rule Andy Wingo
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).