From: rock69
Subject: Possible (serious) bug in SBCL
Date: 
Message-ID: <d008a9b5-bbf7-4bd8-be4e-9c3727e8fe79@s50g2000hsb.googlegroups.com>
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?

From: Chris Russell
Subject: Re: Possible (serious) bug in SBCL
Date: 
Message-ID: <0e4f456e-3280-4d5c-971b-0e50aa0647b9@e39g2000hsf.googlegroups.com>
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)) ?
From: rock69
Subject: Re: Possible (serious) bug in SBCL
Date: 
Message-ID: <96fcb4bd-8483-4111-aa77-d14f0895b509@m36g2000hse.googlegroups.com>
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.
From: Ron Garret
Subject: Re: Possible (serious) bug in SBCL
Date: 
Message-ID: <rNOSPAMon-649302.09273306092008@news.gha.chartermi.net>
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
From: rock69
Subject: Re: Possible (serious) bug in SBCL
Date: 
Message-ID: <40470119-94a6-44bb-9f08-801ccc5e3a14@j22g2000hsf.googlegroups.com>
> Did you mean to type `(,x (,x ,@',y)) ?

Yes, precisely so.