From ... Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!newsfeeds.belnet.be!news.belnet.be!news2.kpn.net!news.kpn.net!nslave.kpnqwest.net!nloc.kpnqwest.net!nmaster.kpnqwest.net!nreader1.kpnqwest.net.POSTED!not-for-mail Newsgroups: comp.lang.lisp Subject: Re: Specialized equal References: <87u1vts33r.fsf@pps.jussieu.fr> <9te8s9$am5$1@rznews2.rrze.uni-erlangen.de> Mail-Copies-To: never From: Erik Naggum Message-ID: <3215280566337392@naggum.net> Organization: Naggum Software, Oslo, Norway Lines: 32 User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.1 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Date: Tue, 20 Nov 2001 21:29:28 GMT X-Complaints-To: newsmaster@KPNQwest.no X-Trace: nreader1.kpnqwest.net 1006291768 193.71.66.49 (Tue, 20 Nov 2001 22:29:28 MET) NNTP-Posting-Date: Tue, 20 Nov 2001 22:29:28 MET Xref: archiver1.google.com comp.lang.lisp:20514 * Jochen Schmidt | Testing for identity is easily done by a pointer comparison. I think it is most pedagogical to quickly say that eq compares machine words with machine instructions and then make sure that you answer "use eql, instead" when the newbie asks about the internal representation of Lisp objects. I would say that eq is for advanced users. If a machine word cannot hold a number, it needs to be stored elsewhere. This is the difference between a fixnum and bignum. | And be ensured that both behaviors EQ _and_ EQL is useful because it | might be _very_ interesting for some applications to compare | non-immediate numbers like bignums by reference! (Think of topics like | ressource-management, memory-management a. s. o.) I think the more important reason is that eq can, and is expected to, be implemented with a single machine instruction, while eql has no upper bound on its execution time. (Consider comparing for equality when the numbers differ only in the bit compared last, and that there is no upper bound on the number of bits in a number.) If eq is true, eql is true, but if eq is false, eql can only be true if the object types are eq and are numbers. So the cost of eql is relatively small until you compare bignums or floats, but if you know you are not comparing numbers, I prefer to make that knowledge explicit by using eq. /// -- Norway is now run by a priest from the fundamentalist Christian People's Party, the fifth largest party representing one eighth of the electorate. -- Carrying a Swiss Army pocket knife in Oslo, Norway, is a criminal offense.