unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
* 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

* Re: define-syntax-rule
  2011-09-02  9:43 define-syntax-rule Andy Wingo
@ 2011-09-03 20:25 ` Ludovic Courtès
  2011-09-04 10:11   ` define-syntax-rule Andy Wingo
  0 siblings, 1 reply; 3+ messages in thread
From: Ludovic Courtès @ 2011-09-03 20:25 UTC (permalink / raw)
  To: guile-devel

Hi Andy!

Andy Wingo <wingo@pobox.com> skribis:

>     @deffn {Syntax} define-syntax-rule (keyword . pattern) [docstring] template
>     Define @var{keyword} as a new @code{syntax-rules} macro with one clause.
>     @end deffn

Do other implementations have this macro?

Thanks,
Ludo’.




^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: define-syntax-rule
  2011-09-03 20:25 ` define-syntax-rule Ludovic Courtès
@ 2011-09-04 10:11   ` Andy Wingo
  0 siblings, 0 replies; 3+ messages in thread
From: Andy Wingo @ 2011-09-04 10:11 UTC (permalink / raw)
  To: Ludovic Courtès; +Cc: guile-devel

On Sat 03 Sep 2011 22:25, ludo@gnu.org (Ludovic Courtès) writes:

> Andy Wingo <wingo@pobox.com> skribis:
>
>>     @deffn {Syntax} define-syntax-rule (keyword . pattern) [docstring] template
>>     Define @var{keyword} as a new @code{syntax-rules} macro with one clause.
>>     @end deffn
>
> Do other implementations have this macro?

Racket does, and ISTR they are happy with it.

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).