Yet more nits for syntax-rules

4 views
Skip to first unread message

Chris Hanson

unread,
Dec 29, 2022, 9:56:02 PM12/29/22
to scheme-reports-wg1, Taylor Campbell
1. Taylor Campbell pointed out that the text explaining the nesting of
ellipses in templates is ambiguous:

Pattern variables that occur in subpatterns followed by one or more
instances of the identifier <ellipsis> are allowed only in subtemplates
that are followed by as many instances of <ellipsis>.

In particular, the phrase “as many” could be interpreted to mean “the same
number of” or “at least as many”. I interpreted it as the former, while
Taylor interpreted it as the latter.

I’d appreciate some clarification on this point.

2. My reading of the template syntax appears to rule out templates like that
in:

(define-syntax flatten
(syntax-rules ()
((flatten f (a ...) ...)
(f a ... ...))))

but for some reason I can’t remember, I explicitly implemented this. Is it
the case that multiple ellipses are permitted as in this example?


Alex Shinn

unread,
Dec 31, 2022, 7:34:52 PM12/31/22
to scheme-re...@googlegroups.com, Taylor Campbell
On Fri, Dec 30, 2022 at 11:56 AM Chris Hanson <c...@chris-hanson.org> wrote:
1. Taylor Campbell pointed out that the text explaining the nesting of
ellipses in templates is ambiguous:

    Pattern variables that occur in subpatterns followed by one or more
    instances of the identifier <ellipsis> are allowed only in subtemplates
    that are followed by as many instances of <ellipsis>.

In particular, the phrase “as many” could be interpreted to mean “the same
number of” or “at least as many”.  I interpreted it as the former, while
Taylor interpreted it as the latter.

Note this text is unchanged from R5RS, and is one place we probably should have clarified.

I think it's ambiguous, but in practice the latter is commonly implemented, and many macros depend on this.
Some macros are _much_ harder to write with the more strict interpretation.

You can also consider a certain symmetry with pattern variables not wrapped in ellipsis and non-pattern variables,
which are allowed in subtemplates followed by any instances of ellipsis.

Happy New Year!

--
Alex

Reply all
Reply to author
Forward
0 new messages