Subject: Re: Specialized equal From: Erik Naggum <firstname.lastname@example.org> Date: Tue, 20 Nov 2001 21:29:28 GMT Newsgroups: comp.lang.lisp Message-ID: <email@example.com> * 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.