From: Andy Wingo <wingo@pobox.com>
To: guile-devel <guile-devel@gnu.org>
Subject: define-syntax-rule
Date: Fri, 02 Sep 2011 11:43:41 +0200 [thread overview]
Message-ID: <87k49r46uq.fsf@pobox.com> (raw)
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/
next reply other threads:[~2011-09-02 9:43 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-09-02 9:43 Andy Wingo [this message]
2011-09-03 20:25 ` define-syntax-rule Ludovic Courtès
2011-09-04 10:11 ` define-syntax-rule Andy Wingo
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/guile/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87k49r46uq.fsf@pobox.com \
--to=wingo@pobox.com \
--cc=guile-devel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).