[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] psyntax: custom ellipses using 'with-ellipsis' or R7RS synta
From: |
Mark H Weaver |
Subject: |
Re: [PATCH] psyntax: custom ellipses using 'with-ellipsis' or R7RS syntax-rules |
Date: |
Thu, 09 Jan 2014 18:07:16 -0500 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) |
address@hidden (Ludovic Courtès) writes:
> Mark H Weaver <address@hidden> skribis:
>
>> address@hidden (Ludovic Courtès) writes:
>>
>>> Does something like this work:
>>>
>>> (define-syntax define-inline
>>> (with-ellipsis ---
>>> (syntax-rules ()
>>> ((_ (name parms ---) exp ---)
>>> (define-syntax name
>>> (syntax-rules ()
>>> ((_ args (--- ---))
>>> ((lambda (parms ---) exp ---)
>>> args (--- ---)))))))))
>>
>> No, because as noted in the docs, the custom ellipsis does not propagate
>> to the generated code.
>
> OK, right; it’d work with ‘with-ellipsis’ repeated after the inner
> ‘define-syntax’ I suppose.
Yes.
> Actually my question was more about the ellipsis escaping form
> (... ...). It is affected by ‘with-ellipsis’, right?
Yes, so the following works:
(define-syntax define-inline
(with-ellipsis ---
(syntax-rules ()
((_ (name parms ---) exp ---)
(define-syntax name
(with-ellipsis (--- ---)
(syntax-rules ()
((_ args (--- ---))
((lambda (parms ---) exp ---)
args (--- ---))))))))))
Needless to say, the whole point of custom ellipses is to avoid having
to ever escape ellipses, but you can still do it.
>> Note that as currently implemented, the effect of 'with-ellipsis'
>> also does not propagate into nested syntax definition forms such as
>> 'let-syntax', 'letrec-syntax', and 'define-syntax'. We could go either
>> way on this.
>
> Well, I think it’s fine this way, but then again I’ve been living in
> world without that feature. ;-)
>
> How does R7RS syntax-rules behave in that respect? I guess we should
> just follow suit.
In R7RS, custom ellipsis is not part of the lexical environment, and
thus does not propagate at all. A custom ellipsis affects only the
patterns and templates of the 'syntax-rules' macro it is passed to.
I ended up making the effect of 'with-ellipsis' propagate into syntax
definition forms, since the semantics seem simpler to me.
I pushed this and the 'syntax-error' patch to stable-2.0.
Thanks!
Mark