Experimenting with backquotes, I think I've found a pretty serious bug
in the backquote expansion implementation in SBCL. Here's what happens
with the following code:
In SBCL:
* (defvar x 5)
X
* (defvar y '(2 3 5 7))
Y
* `(,x `(,',x ,',@y))
(5 `(5 2)) <---- Not what should have come out (or at least what I
was expecting).
In CLISP:
[1]> (defvar x 5)
X
[2]> (defvar y '(2 3 5 7))
Y
[3]> `(,x `(,',x ,',@y))
(5 '(5 2 3 5 7)) <---- This is exactly what I thought should come
out.
Opinions?
On 6 Sep, 12:55, rock69 <···········@gmail.com> wrote:
> Experimenting with backquotes, I think I've found a pretty serious bug
> in the backquote expansion implementation in SBCL. Here's what happens
> with the following code:
>
> In SBCL:
> * (defvar x 5)
>
> X
> * (defvar y '(2 3 5 7))
>
> Y
> * `(,x `(,',x ,',@y))
>
> (5 `(5 2)) <---- Not what should have come out (or at least what I
> was expecting).
>
> In CLISP:
> [1]> (defvar x 5)
> X
> [2]> (defvar y '(2 3 5 7))
> Y
> [3]> `(,x `(,',x ,',@y))
> (5 '(5 2 3 5 7)) <---- This is exactly what I thought should come
> out.
>
> Opinions?
Yes, you're splicing multiple arguments into quote, with undefined
consequences.
If we delay some of the evaluation:
> `(,x (,x ',@y))
(5 (5 (QUOTE 2 3 5 7)))
but quote normally only consumes one argument.
Did you mean to type `(,x (,x ,@',y)) ?
On Sep 6, 2:18 pm, Chris Russell <·····················@gmail.com>
wrote:
> On 6 Sep, 12:55, rock69 <···········@gmail.com> wrote:
>
>
>
> > Experimenting with backquotes, I think I've found a pretty serious bug
> > in the backquote expansion implementation in SBCL. Here's what happens
> > with the following code:
>
> > In SBCL:
> > * (defvar x 5)
>
> > X
> > * (defvar y '(2 3 5 7))
>
> > Y
> > * `(,x `(,',x ,',@y))
>
> > (5 `(5 2)) <---- Not what should have come out (or at least what I
> > was expecting).
>
> > In CLISP:
> > [1]> (defvar x 5)
> > X
> > [2]> (defvar y '(2 3 5 7))
> > Y
> > [3]> `(,x `(,',x ,',@y))
> > (5 '(5 2 3 5 7)) <---- This is exactly what I thought should come
> > out.
>
> > Opinions?
>
> Yes, you're splicing multiple arguments into quote, with undefined
> consequences.
> If we delay some of the evaluation:
>
> > `(,x (,x ',@y))
>
> (5 (5 (QUOTE 2 3 5 7)))
>
> but quote normally only consumes one argument.
>
> Did you mean to type `(,x (,x ,@',y)) ?
I see, thank you.
In article
<····································@m36g2000hse.googlegroups.com>,
rock69 <···········@gmail.com> wrote:
> On Sep 6, 2:18�pm, Chris Russell <·····················@gmail.com>
> wrote:
> > On 6 Sep, 12:55, rock69 <···········@gmail.com> wrote:
> >
> >
> >
> > > Experimenting with backquotes, I think I've found a pretty serious bug
> > > in the backquote expansion implementation in SBCL. Here's what happens
> > > with the following code:
> >
> > > In SBCL:
> > > * (defvar x 5)
> >
> > > X
> > > * (defvar y '(2 3 5 7))
> >
> > > Y
> > > * `(,x `(,',x ,',@y))
> >
> > > (5 `(5 2)) � <---- Not what should have come out (or at least what I
> > > was expecting).
> >
> > > In CLISP:
> > > [1]> (defvar x 5)
> > > X
> > > [2]> (defvar y '(2 3 5 7))
> > > Y
> > > [3]> `(,x `(,',x ,',@y))
> > > (5 '(5 2 3 5 7)) � �<---- This is exactly what I thought should come
> > > out.
> >
> > > Opinions?
> >
> > Yes, you're splicing multiple arguments into quote, with undefined
> > consequences.
> > If we delay some of the evaluation:
> >
> > > `(,x (,x ',@y))
> >
> > (5 (5 (QUOTE 2 3 5 7)))
> >
> > but quote normally only consumes one argument.
> >
> > Did you mean to type `(,x (,x ,@',y)) ?
>
> I see, thank you.
This seems like a bug in both SBCL and CLISP (a different bug in each
case). The results should be:
Welcome to Clozure Common Lisp Version 1.2-r9826M-RC1 (DarwinX8664)!
? (defvar x 5)
X
? (defvar y '(2 3 5 7))
Y
? `(,x `(,',x ,',@y))
(5 (LIST* '5 (LIST (QUOTE 2 3 5 7))))
Also:
? `(,x (,x ,@',y))
> Error: Reader error on #<GUI::COCOA-LISTENER-INPUT-STREAM #x3000417F020D>:
> Comma not inside backquote
Note that both SBCL and CLisp correctly produce an error in this case.
rg