(When I initially replied to the issues raised by Panicz, I missed to forward my reply to the mailing list as well.)

-------- Weitergeleitete Nachricht --------
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.

Am 08.03.2017 um 21:54 schrieb Panicz Maciej Godek:
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
(define f1 <v1>)
(define f2 <v2>)
...
(define fn <vn>)
expression

was supposed to get transformed into something that begins with
(let ((f1 (lambda ((f1 f2 ... fn)) f1))
      (f2 (lambda ((f1 f2 ... fn)) f2))
      ...
      (fn (lambda ((f1 f2 ... fn)) fn)))
  <inner-context>)

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

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

However, if we allow the consecutive ellipses, as in the proposal, the templates and patterns are no longer symmetrical.
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.

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

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

I have written a pattern matcher (http://snow-fort.org/s/rapid-scheme.org/marc/rapid/match/0.1.3/index.html), which would have used consecutive ellipses if they were provided by R7RS.

So, no, this SRFI wasn't born out of theoretical considerations but from studies of published code and own programming.

--

Marc

To unsubscribe from this list please go to http://www.simplelists.com/confirm.php?u=HPnO69Ijc0fnLAmtlfwu0Yu43aG4fvix