[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]


From: Andy Wingo
Subject: define-syntax-rule
Date: Fri, 02 Sep 2011 11:43:41 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.3 (gnu/linux)

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

    @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:

    (define-syntax-rule (when c e ...)
      (if c (begin e ...)))
    @end example

Happy hacking,


reply via email to

[Prev in Thread] Current Thread [Next in Thread]