help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Are two symbols `equal' iff they are `eq'?


From: Marcin Borkowski
Subject: Re: Are two symbols `equal' iff they are `eq'?
Date: Sun, 09 Aug 2015 09:42:29 +0200

On 2015-08-09, at 02:31, Joost Kremers <address@hidden> wrote:

> Marcin Borkowski wrote:
>> As in the subject; neither the manual nor the docstring for `equal' are
>> very clear on this.  (The docstring for `equal' says: "Symbols must
>> match exactly.", which -- I would guess -- means `eq', but I'm not
>> sure.)
>
> Quoting the description of `equal` in the Elips manual:
>
> ,----
> |  -- Function: equal object1 object2
> |      This function returns `t' if OBJECT1 and OBJECT2 have equal
> |      components, and `nil' otherwise.  Whereas `eq' tests if its
> |      arguments are the same object, `equal' looks inside nonidentical
> |      arguments to see if their elements or contents are the same.  So,
> |      if two objects are `eq', they are `equal', but the converse is not
> |      always true.
> `----
>
> (info "(elisp) Equality Predicates")
>
> Seems to me to be very clear: objects can be `equal` without being `eq`.
> (But they cannot be `eq` if they're not `equal`.)

Of course.  But what about symbols?

I cannot make two symbols which would be `equal' but not `eq'.  (This
doesn't mean that it's impossible, though - only that I don't know how
to do it, if it's possible.)  I tried same-named symbols in different
obarrays, a mic of uninterned and interned symbols, and two uninterned
symbols with the same name.  So I strongly suspect that `eq' and `equal'
for symbols are the same.  I even did something as contrived as

(defun eq (a b) (message "Haha!))
(equal 'a 'a)

Of course, it only showed that `equal' does not /call/ `eq' for
symbols, but it's still not a definitive answer.

(Note to purists: I did it in a separate instance of Emacs, and
immediately killed that instance, so that I didn't accidentally open
a portal to a world full of terrible monsters or something like that.)

Best,

-- 
Marcin Borkowski
http://octd.wmi.amu.edu.pl/en/Marcin_Borkowski
Faculty of Mathematics and Computer Science
Adam Mickiewicz University



reply via email to

[Prev in Thread] Current Thread [Next in Thread]