Subject: Re: `(,@10)
From: rpw3@rpw3.org (Rob Warnock)
Date: Sat, 13 Dec 2008 08:50:30 -0600
Newsgroups: comp.lang.lisp
Message-ID: <m9-dncZr2NwrVt7UnZ2dnUVZ_gKdnZ2d@speakeasy.net>
Kaz Kylheku  <kkylheku@gmail.com> wrote:
+---------------
| Rob Warnock <rpw3@rpw3.org> wrote:
| > Kaz Kylheku  <kkylheku@gmail.com> wrote:
| > +---------------
| >| What if I want to annotate a cons which is constructed from two vectors?
| >|  `(#(,a ,b ,c) . #(,d ,e ,f))
| >| Oops.
| > +---------------
| >
| > What "oops"?
| >     > (let ((a 1) (b 2) (c 3) (d 4) (e 5) (f 6))
| > 	`(#(,a ,b ,c) . #(,d ,e ,f)))
| >     (#(1 2 3) . #(4 5 6))
| >     >
| 
| Good.  The oops is that the spec doesn't require the above behavior.
| The form matches the case:
| 
|  `(x1 . atom) -> (append [x1] (quote atom))
| 
| Where x1 is #(,a ,b ,c) and atom is #(,d ,e ,f),
| and [x1] follows the [form] -> (list `form) transformation.
| Hence the expansion is (append (list `#(,a b c)) (quote #(,d ,e ,f))
| which is nonsense with dangling commas.
+---------------

Another possible interpretation -- not in obvious direct contradiction
to CLHS 2.4.6 [if one allows non-conflicting extensions] -- is that
there is a rule missing from CLHS 2.4.6:

    `(x1 . x2)  ==>  (cons `x1 `x2)

which for your example would result in this expansion:

    `(#(,a ,b ,c) . #(,d ,e ,f))) ==>
    (cons `#(,a ,b ,c) `#(,d ,e ,f))) ==>
    (cons (apply #'vector `(,a ,b ,c)) (apply #'vector `(,d ,e ,f))) ==>
    (cons (apply #'vector (append (list a) (list b) (list c)))
	  (apply #'vector (append (list d) (list e) (list f))))


-Rob

p.s. FWIW, the actual transformation implemented by CMUCL for the
same example is this:

    `(#(,a ,b ,c) . #(,d ,e ,f))) ==>
    (lisp::backq-cons (lisp::backq-vector (lisp::backq-list a b c))
		      (lisp::backq-vector (lisp::backq-list d e f))) ==>
    (cons (coerce (list a b c) 'simple-vector)
	  (coerce (list d e f) 'simple-vector))

-----
Rob Warnock			<rpw3@rpw3.org>
627 26th Avenue			<URL:http://rpw3.org/>
San Mateo, CA 94403		(650)572-2607