[Top][All Lists]

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

Re: Patch to add (define-syntax (foo bar) ...) support

From: Ian Price
Subject: Re: Patch to add (define-syntax (foo bar) ...) support
Date: Fri, 02 Sep 2011 14:33:09 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.2 (gnu/linux)

Andy Wingo <address@hidden> writes:

> On the whole I am skeptical.  But, Chez Scheme and Racket both made this
> change.  So I could go either way, though I would like thoughts from
> other people before proceeding.

While I like the change, another solution is to try to make a
'syntax-case' form that returns a lambda like syntax-rules.


(define-syntax foo
  (syntax-case* ()
    ((foo ...) ...)

or if we need access to the syntax object for e.g. unhygienic macros

(define-syntax foo
  (syntax-case* stx ()
    ((foo ...) ...)

I haven't used this in practice, but it would cut down on some
consistent verbosity. A rough implementation could be

(define-syntax syntax-case*
  (lambda (stx)  ; goodbye forever old friend ;-)
    (syntax-case stx ()
      ((syntax-case* syntax-object literals rule rules ...)
       (identifier? #'syntax-object)
       #'(lambda (syntax-object)
           (syntax-case syntax-object literals
             rules ...)))
      ((syntax-case* literals rule rules ...)
       #'(lambda (syntax-object)
           (syntax-case syntax-object literals
             rules ...))))))

It wouldn't match up with the meaning of syntax-case* in racket, but if
that's important to anyone, feel free to come up with another name :-)

Ian Price

"Programming is like pinball. The reward for doing it well is
the opportunity to do it again" - from "The Wizardy Compiled"

reply via email to

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