Re: Bug report

Taylor R Campbell <[email protected]> Mon, 17 Jan 2011 16:36:59 +0000
Newsgroups gmane.lisp.scheme.scheme48
Message-ID <[email protected]>
   Date: Mon, 17 Jan 2011 08:20:21 +0100
   From: Michael Sperber <[email protected]>

   Emmanuel Medernach <[email protected]> writes:

   > (define-syntax foo
   > (syntax-rules ()
   >   ((foo (a ...) (b ...))
   >    (list (list a b ...) ...))))
   >
   > However it works fine with other Scheme implementations:
   > (foo (1 2 3) (4 5)) => ((1 4 5) (2 4 5) (3 4 5))

   What is it supposed to mean when (a ...) and (b ...) do not have the
   same length?

This is the case in the example shown.  The transformation is
unambiguous, but it could be construed to violate the sentence in the
R5RS, Section 4.3.2 `Pattern language', p. 15, that reads: `Pattern
variables that occur in subpatterns followed by one or more instances
of the identifier ``...'' are allowed only in subtemplates that are
followed by as many instances of ``...'.'  In the pattern, b is
followed by one ellipsis, but in the template, it is followed by two.

You were probably thinking of transforming (foo (a ...) (b ...)) into
(list (list a b) ...), which of course makes no sense for (foo (1 2 3)
(4 5)).  Some Scheme systems support this nevertheless -- Scheme48 and
MIT Scheme just truncate the longer list in the bogus case.

Another cute trick is transforming (foo (a ...) ...) into (foo a ...
...), which Scheme48 supports, but which some other Scheme systems
such as MIT Scheme don't.  Whether this is kosher in the R5RS is a
little fuzzier; it depends on whether one is willing to weasel about
with the term `followed by'.