Subject: Re: backquoting: are lispworks, sbcl, clisp conformant?
From: rpw3@rpw3.org (Rob Warnock)
Date: Sun, 18 Jan 2009 20:04:57 -0600
Newsgroups: comp.lang.lisp
Message-ID: <Qt-dnYUGAclUQu7UnZ2dnUVZ_vGdnZ2d@speakeasy.net>
Kaz Kylheku  <kkylheku@gmail.com> wrote:
+---------------
| Rob Warnock <rpw3@rpw3.org> wrote:
| > Uh... What do you think (APPEND (LIST 0)) evaluates *to*?!?
| >     > (append (list 0))
| >     (0)
| >     > 
| > And what do you think `(,0) evaluates to?
| >
| >     > `(,0)
| >     (0)
| >     > 
| 
| This is not the right way to argue this. Multiple invocations of (LIST 0)
| are not in fact allowed to return objects that share list structure.
+---------------

Good point. The correct argument for the OP's test case is the READ+EVAL
indeterminacy of form under EQUAL... which I *did* make later.

+---------------
| > What you're missing is that the CLHS specifically *doesn't* specify
| > whether backquote evaluation is done at READ time or at EVAL time,
| 
| This is quite wrong, Rob. What is not specified is whether the
| /expansion/ of backquote (translating the syntax into code) is done
| at read time or later, or some combination from different times
| (like translating the notation to a macro at read time, and expanding
| the macro at macro-expansion time).
+---------------

You deleted the critical CLHS quote, which I will repeat:

    An implementation is free to interpret a backquoted form F1 as
    any form F2 that, when evaluated, will produce a result that is
    the same under equal as the result implied by the above definition...

This implies that form F2 is free to be a *constant* [where the original
backquoted form can be fully expanded to such a constant at READ time],
as long as that constant is EQUAL to the canonical expansion given in
2.4.6, which, for the OP's test case, '(0) is.

+---------------
| Of course evaluation is done at eval time. What part of "eval"
| being a prefix of "evaluation" isn't clear? :) :) :)
+---------------

I'll try again, with more precision: The implementation of backquote
is free to produce at READ time, if it is able to, any alternate form
[perhaps simpler, perhaps more complex] than the canonical expansion
given in 2.4.6, provided that that other form, when evaluated (at EVAL
time), is EQUAL to the evaluation of the canonical expansion given in
2.4.6. That alternate form may indeed even be a constant. 

*If* the backquote expansion produced at READ time *is* a constant,
then of course a function returning the evaluation of that expansion
will return the "same" (under EQL) result each time it is called.
And in fact, if the result is not a number or a character, the
multiple results will all be EQ.

If, on the other hand, the specific implementation of backquote chooses
*not* to return a constant, but a form which actively computes a new
result each time it is evaluated, that's fine, too, as long as all such
results are EQUAL (and EQUAL to the evaluation of the canonical form).
They might well *not* be EQL or EQ, however...

So the "equality" status of the OP's original (DEFUN FF () `(,0))
example function, is indeterminant. The values of multiple calls
of FF *must* be EQUAL; they might or might not be EQL or EQ.

Is that better?


-Rob

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