budden <budden-lisp@mail.ru> wrote:
+---------------
| > (defun ff () `(,0))
| ff
| > (eq (ff) (ff))
| this returns:
| t (in lispworks, sbcl, clisp)
| nil (in allegro, clozure cl)
|
| On my opinion, returning t is non-conformant.
+---------------
On the contrary, what EQ returns in this case is not specified.
T is a perfectly acceptable, and so is NIL.
+---------------
| Standard (section 2.4.6,
| http://www.lispworks.com/documentation/HyperSpec/Body/02_df.htm)
| states:
| "
| `(x1 x2 x3 ... xn . atom) may be interpreted to mean
| (append [ x1] [ x2] [ x3] ... [ xn] (quote atom))
| where the brackets are used to indicate a transformation of an xj
| as follows:
| -- [form] is interpreted as (list `form), which contains a
| backquoted form that must then be further interpreted.
| -- [,form] is interpreted as (list form).
| ..."
|
| so, `(,0) should mean (append (list 0)), but not '(0), as it is
| interpreted in first three implementations I listed
+---------------
Uh... What do you think (APPEND (LIST 0)) evaluates *to*?!?
> (append (list 0))
(0)
>
And what do you think `(,0) evaluates to?
> `(,0)
(0)
>
So the *only* thing you're quibbling about is whether the evaluation
of the (APPEND (LIST 0)) is done at READ time, in which case the
(EQ (FF) (FF)) will likely return T [since it's returning the identical
cons cell embedded in the function definition], or whether the evaluation
of the (APPEND (LIST 0)) is done at EVAL time, in which case the
(EQ (FF) (FF)) will likely return NIL [since freshly allocated cons
cells are always different under EQ].
What you're missing is that the CLHS specifically *doesn't* specify
whether backquote evaluation is done at READ time or at EVAL time,
only that it follow the rules. From the same CLHS 2.4.6 page that
you referenced above:
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,
provided that the side-effect behavior of the substitute form F2
is also consistent with the description given above.
Read closely: It says "the same under EQUAL", *not* "the same under EQ"!!
And, indeed:
> (equal `(,0) (append (list 0)))
T
>
*All* implementations should return T for (EQUAL (FF) (FF)).
-Rob
-----
Rob Warnock <rpw3@rpw3.org>
627 26th Avenue <URL:http://rpw3.org/>
San Mateo, CA 94403 (650)572-2607