(When I initially replied to the issues raised by Panicz, I
missed to forward my reply to the mailing list as well.)
Betreff: | Re: A few notes with regard to repeated ellipses |
---|---|
Datum: | Thu, 16 Mar 2017 17:33:30 +0100 |
Von: | Marc Nieper-Wißkirchen <xxxxxx@nieper-wisskirchen.de> |
An: | Panicz Maciej Godek <xxxxxx@gmail.com> |
Dear Panicz,
thank you for your comments.
Was it ever a goal to have the same syntax in patterns as in templates? Already without my proposed extension, things like "(foo bar) ..." as a pattern may mean a completely different thing as "(foo bar) ..." as a template, namely depending on whether, say, foo in the template is pattern variable or an identifier inserted into the output.However, it is possible to modify the pattern matcher to handle cases like this as well, which I did. (By the way, the fact that syntax-rules does not allow the same identifier to appear more than once in a pattern also seems like an unnatural and arbitrary limitation)I've noticed that while syntax-rules allows such forms as templates, it does not allow them as patterns (the result of expansion would fail to match).<inner-context>)(fn (lambda ((f1 f2 ... fn)) fn)))(f2 (lambda ((f1 f2 ... fn)) f2))(let ((f1 (lambda ((f1 f2 ... fn)) f1))was supposed to get transformed into something that begins withexpression(define fn <vn>)(define f2 <v2>)(define f1 <v1>)I've recently been implementing a syntax impander -- in addition to expanded form, the syntax expander returned the information about the transformations that it used, thanks to which the syntax expansion process could be reverted.Since I was using my transformer to perform "Y-lining" of definitions, my code of the form
...
...
that is, f1 ... fn were re-bound to name tuple selectors in the <inner-context> (the code works because I modified Scheme to perform destructured bindings in arguments to lambda).
However, if we allow the consecutive ellipses, as in the proposal, the templates and patterns are no longer symmetrical.
I think I don't completely get what you are trying to tell me. In general, the transformation process is not injective, so how do you want to reverse the process? Even without consecutive ellipses in templates, I can write a macro transformer that turns nested lists into flat lists (like Scheme's append procedure), although it is a bit more cumbersome. So consecutive ellipses in templates don't change the power of syntax-rules.And while of course the semantics of the consecutive ellipses in templates are indeed very intuitive, I think we should ask the question whether they should also be allowed in templates (I guess they would need to match lists of lists). However, if we decided to do so, i.e. allow , I think that it would make the "impansions" of macros more difficult: once the form '((1 2 3) (4) (5 6)) is concatenated to (1 2 3 4 5 6), there is no way of transforming it back without storing additional information regarding the shape of the original list.
I have run at least twice across Scheme code that was using consecutive ellipses and that was supposed to be portable. (Unfortunately I have made no notes where I found it.) So, apparently, many Schemers have never thought that this extension may not be in the report because their implementations are happy to support consecutive ellipses.Another question that comes to my mind is whether one could give any examples of some practical application of these "consecutive ellipses" templates", or is it just a purely theoretical construct at this moment?
To unsubscribe from this list please go to http://www.simplelists.com/confirm.php?u=HPnO69Ijc0fnLAmtlfwu0Yu43aG4fvix