Subject: Re: cons to the same object
From: rpw3@rpw3.org (Rob Warnock)
Date: Fri, 16 Mar 2007 04:16:28 -0500
Newsgroups: comp.lang.lisp
Message-ID: <5sednRQszILx_WfYnZ2dnUVZ_qWvnZ2d@speakeasy.net>
Frode Vatvedt Fjeld  <frodef@cs.uit.no> wrote:
+---------------
| Steven Haflich <smh@alum.mit.edu> writes:
| > However, eql in typical implementations is a rather more expensive
| > operation than eq in the false case.  That is sufficient reason for
| > using eq when the arguments are known not to be numbers or
| > characters.
| 
| This was my conclusion also, the last time this was discussed here,
| maybe a couple of years ago: Treat EQ as a shortcut for something
| approximately like
|   (eql (the (not (or number character)) x)
|        (the (not (or number character)) y))
+---------------

Conversely, one may hope that the implementation of EQL is always
at *least* as good as this:

    (or (eq x y)
	(and (characterp x) (characterp y) (char= x y))
	(and (numberp x) (numberp y) (= x y)))

which isn't actually all that slow except for the leaf cases
of "char=" with hugely-complex Unicode and "=" with bignums.


-Rob

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