Re: @ list splicing bug?

From: Adam Warner (usenet_at_consulting.net.nz)
Date: 11/26/03


Date: Wed, 26 Nov 2003 20:20:51 +1300

Hi Kent M Pitman,

>> Should the evaluation of:
>> ``(,',@(loop for arg in '(a b c) collect `(cons ',arg ,arg)))
>>
>> Be:
>> '((cons 'a a) (cons 'b b) (cons 'c c))
>>
>> CMUCL and SBCL return `((cons 'a a)).
>
> FWIW, LW 4.2.7 returns
>
> (QUOTE ((CONS 'A A) (CONS 'B B) (CONS 'C C)))
>
> but I'm not sure this is really right. The expression seems ill-formed
> since you have to do outer-backquote/inner-comma forms first, and after
> the first evaluation you get
>
> `(,(quote (cons 'a a) (cons 'b b) (cons 'c c)))
>
> and I'm not sure that's really even well-formed.

Thank you for your exceptional analysis Kent and Peter. As QUOTE operates
upon a single object I can understand the error in the expansion.

...

> I think you want to write
> ``(,,@(loop for arg in '(a b c) collect `'(cons ',arg ,arg)))
                                            ^
This turned out to be the correct approach! |
                                            +--The critical addition.
Many thanks,
Adam