Re: Bug report
Emmanuel Medernach <[email protected]> Wed, 19 Jan 2011 08:51:03 +0100
| Newsgroups | gmane.lisp.scheme.scheme48 |
|---|---|
| Message-ID | <[email protected]> |
Hello,
Taylor R Campbell a écrit :
> 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.
>
Thanks for pointing to the relevant part of the report.
However when we try this:
(define-syntax bar
(syntax-rules ()
((bar aa (b ...))
'((aa b) ...))))
(bar "test" (1 2 3 4))
;; (("test" 1) ("test" 2) ("test" 3) ("test" 4))
You see there that "test" is repeated. Ok, this is because 'aa' is a template
variable with no ellipsis.
The following one gives an error depending on your implementation:
(define-syntax baz
(syntax-rules ()
((baz (a ...) (b ...))
'(((a ...) b) ...))))
(baz ("test") (1 2 3 4))
I mean if there is more ellipsis in the template than in the pattern, some macro
expanders repeat the whole template variable as it is.
> 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.
>
I suppose this one is vague because (a ...) could match the empty list ?
> 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'.
>
Exactly, we need to clear confusion about that.
Best regards,
--
medernac.vcf
(text/x-vcard, 259 B)
begin:vcard fn:Emmanuel Medernach n:Medernach;Emmanuel org:IN2P3/CNRS ;63177 AUBIERE CEDEX adr:;;;Clermont-Ferrand;;63000;France email;internet:[email protected] title:Laboratoire de Physique Corpusculaire x-mozilla-html:FALSE version:2.1 end:vcard