[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: Chris K. Jester-Young
Subject: Re: Patch to add (define-syntax (foo bar) ...) support
Date: Sun, 3 Jul 2011 17:03:09 -0400
User-agent: Mutt/1.5.20 (2009-06-14)

On Sun, Jul 03, 2011 at 04:44:46PM -0400, Noah Lavine wrote:
> I agree that this is much shorter, but I'm worried about defining the
> short syntax in a way that forces you to choose between syntax-rules
> and syntax-case.

Except, it doesn't. My version doesn't insert either syntax-case or
syntax-rules; it just inserts the lambda and lets you do whatever.

Granted, in practice that makes the shortcut useful for syntax-case
only, but at least it's highly consistent with how define's shortcut
works, and should therefore be less confusing.

>                  What I mean is that you could just as easily have
> (define-syntax (foo bar)
>   ...)
> expand to
> (define-syntax foo
>   (syntax-rules ()
>     ((_ bar) ...)))

Racket resolves this by having a macro called define-syntax-rule, which
allows you to define a one-branch syntax-rules macro. Thus these two
macros are identical:

    (define-syntax-rule (foo bar baz) (...))

    (define-syntax foo
      (syntax-rules ()
        ((_ bar baz) (...))))

> It seems to me that this makes a somewhat arbitrary choice, which
> isn't great. I'd rather see some way to unify the two possibilities,
> but I don't know what that would be. There's also the possibility of
> making it expand to
> (define-syntax foo
>   (syntax-case tmp ...
>     ((bar) ...)))
> because it is more analogous to how regular procedures work.

The problem with this is that this then favours the one-branch variant,
which is not a common case for syntax-case macros.


reply via email to

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