all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Are two symbols `equal' iff they are `eq'?
@ 2015-08-09  0:20 Marcin Borkowski
  2015-08-09  1:52 ` Emanuel Berg
  2015-08-09 15:28 ` Drew Adams
  0 siblings, 2 replies; 24+ messages in thread
From: Marcin Borkowski @ 2015-08-09  0:20 UTC (permalink / raw
  To: Help Gnu Emacs mailing list

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.)

TIA,

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



^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: Are two symbols `equal' iff they are `eq'?
       [not found] <mailman.7993.1439079676.904.help-gnu-emacs@gnu.org>
@ 2015-08-09  0:31 ` Joost Kremers
  2015-08-09  5:16   ` Ian Zimmerman
                     ` (3 more replies)
  0 siblings, 4 replies; 24+ messages in thread
From: Joost Kremers @ 2015-08-09  0:31 UTC (permalink / raw
  To: help-gnu-emacs

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`.)



-- 
Joost Kremers                                   joostkremers@fastmail.fm
Selbst in die Unterwelt dringt durch Spalten Licht
EN:SiS(9)


^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: Are two symbols `equal' iff they are `eq'?
  2015-08-09  0:20 Marcin Borkowski
@ 2015-08-09  1:52 ` Emanuel Berg
  2015-08-09  7:44   ` Marcin Borkowski
  2015-08-09 15:28 ` Drew Adams
  1 sibling, 1 reply; 24+ messages in thread
From: Emanuel Berg @ 2015-08-09  1:52 UTC (permalink / raw
  To: help-gnu-emacs

Marcin Borkowski <mbork@mbork.pl> writes:

> 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.)

If x and y are `equal' iff they are `eq', wouldn't
that make those functions equivalent?

Once again, the born man of action will find out like
this:

    (setq *l1* '(1 2 3))
    (setq *l2* '(1 2 3))

    (eq    *l1* *l2*) ; nil
    (eq    *l1* *l1*) ; t

    (equal *l1* *l2*) ; t

So `eq' is structure, and `equal' is data.

-- 
underground experts united
http://user.it.uu.se/~embe8573




^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: Are two symbols `equal' iff they are `eq'?
  2015-08-09  0:31 ` Are two symbols `equal' iff they are `eq'? Joost Kremers
@ 2015-08-09  5:16   ` Ian Zimmerman
  2015-08-09  7:30     ` Marcin Borkowski
       [not found]   ` <mailman.8007.1439097407.904.help-gnu-emacs@gnu.org>
                     ` (2 subsequent siblings)
  3 siblings, 1 reply; 24+ messages in thread
From: Ian Zimmerman @ 2015-08-09  5:16 UTC (permalink / raw
  To: help-gnu-emacs

On 2015-08-09 00:31 +0000, Joost Kremers wrote:

> Seems to me to be very clear: objects can be `equal` without being `eq`.
> (But they cannot be `eq` if they're not `equal`.)

Objects, yes.  But the OP has specifically asked about _symbols_.

Sorry I don't have the answer.  It may be necessary to inspect the code.
Why do you need to know, Marcin?

-- 
Please *no* private copies of mailing list or newsgroup messages.
Rule 420: All persons more than eight miles high to leave the court.




^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: Are two symbols `equal' iff they are `eq'?
       [not found]   ` <mailman.8007.1439097407.904.help-gnu-emacs@gnu.org>
@ 2015-08-09  5:21     ` Rusi
  2015-08-09  5:33       ` Ian Zimmerman
  0 siblings, 1 reply; 24+ messages in thread
From: Rusi @ 2015-08-09  5:21 UTC (permalink / raw
  To: help-gnu-emacs

On Sunday, August 9, 2015 at 10:46:50 AM UTC+5:30, Ian Zimmerman wrote:
> On 2015-08-09 00:31 +0000, Joost Kremers wrote:
> 
> > Seems to me to be very clear: objects can be `equal` without being `eq`.
> > (But they cannot be `eq` if they're not `equal`.)
> 
> Objects, yes.  But the OP has specifically asked about _symbols_.
> 
> Sorry I don't have the answer.  It may be necessary to inspect the code.
> Why do you need to know, Marcin?

I think it is to be understood that object as the universal set in lisp
ie Symbol ⊆ Object
[Dont know reference for that though]


^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: Are two symbols `equal' iff they are `eq'?
  2015-08-09  5:21     ` Rusi
@ 2015-08-09  5:33       ` Ian Zimmerman
  0 siblings, 0 replies; 24+ messages in thread
From: Ian Zimmerman @ 2015-08-09  5:33 UTC (permalink / raw
  To: help-gnu-emacs

On 2015-08-08 22:21 -0700, Rusi wrote:

> I think it is to be understood that object as the universal set in lisp
> ie Symbol ⊆ Object

And so?  The answer can still be Yes for symbols and No for objects in
general.

This is Aristotelian logic, damned.

-- 
Please *no* private copies of mailing list or newsgroup messages.
Rule 420: All persons more than eight miles high to leave the court.




^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: Are two symbols `equal' iff they are `eq'?
  2015-08-09  5:16   ` Ian Zimmerman
@ 2015-08-09  7:30     ` Marcin Borkowski
  2015-08-09 14:05       ` Michael Heerdegen
  0 siblings, 1 reply; 24+ messages in thread
From: Marcin Borkowski @ 2015-08-09  7:30 UTC (permalink / raw
  To: help-gnu-emacs


On 2015-08-09, at 07:16, Ian Zimmerman <itz@buug.org> wrote:

> On 2015-08-09 00:31 +0000, Joost Kremers wrote:
>
>> Seems to me to be very clear: objects can be `equal` without being `eq`.
>> (But they cannot be `eq` if they're not `equal`.)
>
> Objects, yes.  But the OP has specifically asked about _symbols_.
>
> Sorry I don't have the answer.  It may be necessary to inspect the code.
> Why do you need to know, Marcin?

Curiosity?  Being sure that my code works as expected, or, IOW,
understanding it? ;-)

And inspecting the code didn't help me a lot - that was the second thing
I tried (the first being checking the docs), but I didn't understand
it.  It seems there's a case dispatch, but I didn't see the branch
responsible for symbols.

Thanks anyway,

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



^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: Are two symbols `equal' iff they are `eq'?
  2015-08-09  0:31 ` Are two symbols `equal' iff they are `eq'? Joost Kremers
  2015-08-09  5:16   ` Ian Zimmerman
       [not found]   ` <mailman.8007.1439097407.904.help-gnu-emacs@gnu.org>
@ 2015-08-09  7:42   ` Marcin Borkowski
  2015-08-09 14:03     ` Michael Heerdegen
       [not found]   ` <mailman.8011.1439106166.904.help-gnu-emacs@gnu.org>
  3 siblings, 1 reply; 24+ messages in thread
From: Marcin Borkowski @ 2015-08-09  7:42 UTC (permalink / raw
  To: help-gnu-emacs


On 2015-08-09, at 02:31, Joost Kremers <joost.m.kremers@gmail.com> 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



^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: Are two symbols `equal' iff they are `eq'?
  2015-08-09  1:52 ` Emanuel Berg
@ 2015-08-09  7:44   ` Marcin Borkowski
  0 siblings, 0 replies; 24+ messages in thread
From: Marcin Borkowski @ 2015-08-09  7:44 UTC (permalink / raw
  To: help-gnu-emacs


On 2015-08-09, at 03:52, Emanuel Berg <embe8573@student.uu.se> wrote:

> Marcin Borkowski <mbork@mbork.pl> writes:
>
>> 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.)
>
> If x and y are `equal' iff they are `eq', wouldn't
> that make those functions equivalent?

You didn't read my question.

And I did expermients, much like you suggested.  Only with symbols
(which I asked about), not cons cells/lists.

Best,

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



^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: Are two symbols `equal' iff they are `eq'?
  2015-08-09  7:42   ` Marcin Borkowski
@ 2015-08-09 14:03     ` Michael Heerdegen
  2015-08-09 14:42       ` Marcin Borkowski
  0 siblings, 1 reply; 24+ messages in thread
From: Michael Heerdegen @ 2015-08-09 14:03 UTC (permalink / raw
  To: help-gnu-emacs

Marcin Borkowski <mbork@mbork.pl> writes:

> I cannot make two symbols which would be `equal' but not `eq'.

Unlike what your subject says, you seem to want to know

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

Which is the more interesting question.

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

This is not a good test when the call to `eq' is done from C.  So, a
negative result doesn't mean anything.


Michael.




^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: Are two symbols `equal' iff they are `eq'?
  2015-08-09  7:30     ` Marcin Borkowski
@ 2015-08-09 14:05       ` Michael Heerdegen
  2015-08-09 15:10         ` Marcin Borkowski
  0 siblings, 1 reply; 24+ messages in thread
From: Michael Heerdegen @ 2015-08-09 14:05 UTC (permalink / raw
  To: help-gnu-emacs

Marcin Borkowski <mbork@mbork.pl> writes:

> And inspecting the code didn't help me a lot - that was the second thing
> I tried (the first being checking the docs), but I didn't understand
> it.  It seems there's a case dispatch, but I didn't see the branch
> responsible for symbols.

I guess you missed the "then" branch of the "if (depth > 10)" clause.


Michael.




^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: Are two symbols `equal' iff they are `eq'?
  2015-08-09 14:03     ` Michael Heerdegen
@ 2015-08-09 14:42       ` Marcin Borkowski
  2015-08-09 14:47         ` Michael Heerdegen
  0 siblings, 1 reply; 24+ messages in thread
From: Marcin Borkowski @ 2015-08-09 14:42 UTC (permalink / raw
  To: help-gnu-emacs


On 2015-08-09, at 16:03, Michael Heerdegen <michael_heerdegen@web.de> wrote:

> Marcin Borkowski <mbork@mbork.pl> writes:
>
>> I cannot make two symbols which would be `equal' but not `eq'.
>
> Unlike what your subject says, you seem to want to know
>
>   Are two symbols `eq' iff they are `equal'?
>
> Which is the more interesting question.

No, it's the same question.
https://en.wikipedia.org/w/index.php?title=Iff&redirect=no

>> (defun eq (a b) (message "Haha!))
>> (equal 'a 'a)
>
> This is not a good test when the call to `eq' is done from C.  So, a
> negative result doesn't mean anything.

That's what I suspected.

> Michael.

Thanks,

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



^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: Are two symbols `equal' iff they are `eq'?
  2015-08-09 14:42       ` Marcin Borkowski
@ 2015-08-09 14:47         ` Michael Heerdegen
  0 siblings, 0 replies; 24+ messages in thread
From: Michael Heerdegen @ 2015-08-09 14:47 UTC (permalink / raw
  To: help-gnu-emacs

Marcin Borkowski <mbork@mbork.pl> writes:

> https://en.wikipedia.org/w/index.php?title=Iff&redirect=no

I thought this was a typo.


Michael.




^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: Are two symbols `equal' iff they are `eq'?
  2015-08-09 14:05       ` Michael Heerdegen
@ 2015-08-09 15:10         ` Marcin Borkowski
  2015-08-09 15:19           ` Eli Zaretskii
  0 siblings, 1 reply; 24+ messages in thread
From: Marcin Borkowski @ 2015-08-09 15:10 UTC (permalink / raw
  To: help-gnu-emacs


On 2015-08-09, at 16:05, Michael Heerdegen <michael_heerdegen@web.de> wrote:

> Marcin Borkowski <mbork@mbork.pl> writes:
>
>> And inspecting the code didn't help me a lot - that was the second thing
>> I tried (the first being checking the docs), but I didn't understand
>> it.  It seems there's a case dispatch, but I didn't see the branch
>> responsible for symbols.
>
> I guess you missed the "then" branch of the "if (depth > 10)" clause.

???

The "then" part seems to contain the "case" I mentioned.  After that,
there is this:

 tail_recurse:
  QUIT;
  if (EQ (o1, o2))
    return 1;

From the capitalization I would guess that QUIT is a C macro.  From its
name I would guess that anything after it is irrelevant;-).  Well,
joking aside, I found its definition in the source; do I get it right
that it quits if something like C-g happens?  If yes, I'd be curious why
it is here.  Apart from that, it seems that I was right: `equal' for
symbols just calls `eq' (C EQ, not Lisp eq, to be more precise).

So I guess I found the answer.  Thanks for your help!

> Michael.

Best,

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



^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: Are two symbols `equal' iff they are `eq'?
  2015-08-09 15:10         ` Marcin Borkowski
@ 2015-08-09 15:19           ` Eli Zaretskii
  2015-08-09 15:45             ` Marcin Borkowski
  0 siblings, 1 reply; 24+ messages in thread
From: Eli Zaretskii @ 2015-08-09 15:19 UTC (permalink / raw
  To: help-gnu-emacs

> From: Marcin Borkowski <mbork@mbork.pl>
> Date: Sun, 09 Aug 2015 17:10:06 +0200
> 
>  tail_recurse:
>   QUIT;
>   if (EQ (o1, o2))
>     return 1;
> 
> >From the capitalization I would guess that QUIT is a C macro.  From its
> name I would guess that anything after it is irrelevant;-).  Well,
> joking aside, I found its definition in the source; do I get it right
> that it quits if something like C-g happens?

Yes.

> If yes, I'd be curious why it is here.

To allow the user to interrupt a (potentially) long operation.

> Apart from that, it seems that I was right: `equal' for
> symbols just calls `eq' (C EQ, not Lisp eq, to be more precise).

What else could it possibly do?



^ permalink raw reply	[flat|nested] 24+ messages in thread

* RE: Are two symbols `equal' iff they are `eq'?
  2015-08-09  0:20 Marcin Borkowski
  2015-08-09  1:52 ` Emanuel Berg
@ 2015-08-09 15:28 ` Drew Adams
  2015-08-09 15:46   ` Marcin Borkowski
       [not found]   ` <mailman.8032.1439135226.904.help-gnu-emacs@gnu.org>
  1 sibling, 2 replies; 24+ messages in thread
From: Drew Adams @ 2015-08-09 15:28 UTC (permalink / raw
  To: Marcin Borkowski, Help Gnu Emacs mailing list

> 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.)

Yes.  `equal' requires symbols to have the same name, value,
function definition, and plist, and to be interned in the same
obarray.  They need to be the same Lisp object (a symbol).

In sum: they need to be `eq'.

Emacs Lisp doesn't have a spec (just its code, and some doc).
But this is what the Common Lisp spec says about `equal' for
symbols:

 Returns true if x and y are structurally similar (isomorphic)
 objects.  Objects are treated as follows by equal.

 * Symbols, Numbers, and Characters
   equal is true of two objects if they are symbols that are eq,
                                            ^^^^^^^^^^^^^^^^^^^
   if they are numbers that are eql, or if they are characters
   that are eql.



^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: Are two symbols `equal' iff they are `eq'?
       [not found]   ` <mailman.8011.1439106166.904.help-gnu-emacs@gnu.org>
@ 2015-08-09 15:38     ` Joost Kremers
  0 siblings, 0 replies; 24+ messages in thread
From: Joost Kremers @ 2015-08-09 15:38 UTC (permalink / raw
  To: help-gnu-emacs

Marcin Borkowski wrote:
>
> On 2015-08-09, at 02:31, Joost Kremers <joost.m.kremers@gmail.com> wrote:
>>
>> 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?

Well, since symbols are objects, the same rule applies. My bad, I didn't
realise you were already aware of that and were asking a more specific
question.



-- 
Joost Kremers                                   joostkremers@fastmail.fm
Selbst in die Unterwelt dringt durch Spalten Licht
EN:SiS(9)


^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: Are two symbols `equal' iff they are `eq'?
  2015-08-09 15:19           ` Eli Zaretskii
@ 2015-08-09 15:45             ` Marcin Borkowski
  2015-08-09 18:19               ` Eli Zaretskii
  2015-08-10 15:26               ` Nicolas Richard
  0 siblings, 2 replies; 24+ messages in thread
From: Marcin Borkowski @ 2015-08-09 15:45 UTC (permalink / raw
  To: help-gnu-emacs


On 2015-08-09, at 17:19, Eli Zaretskii <eliz@gnu.org> wrote:

>> From: Marcin Borkowski <mbork@mbork.pl>
>> Date: Sun, 09 Aug 2015 17:10:06 +0200
>> 
>>  tail_recurse:
>>   QUIT;
>>   if (EQ (o1, o2))
>>     return 1;
>> 
>> >From the capitalization I would guess that QUIT is a C macro.  From its
>> name I would guess that anything after it is irrelevant;-).  Well,
>> joking aside, I found its definition in the source; do I get it right
>> that it quits if something like C-g happens?
>
> Yes.
>
>> If yes, I'd be curious why it is here.
>
> To allow the user to interrupt a (potentially) long operation.

That's obvious, I just wondered why at this point.

>> Apart from that, it seems that I was right: `equal' for
>> symbols just calls `eq' (C EQ, not Lisp eq, to be more precise).
>
> What else could it possibly do?

It could e.g. compare the string representation, so two symbols with the
same name but in different obarrays, or one interned and the other not,
could be equal but not eq.  (I'm not sure whether this would be useful,
though - just a thought.)

Regards,

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



^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: Are two symbols `equal' iff they are `eq'?
  2015-08-09 15:28 ` Drew Adams
@ 2015-08-09 15:46   ` Marcin Borkowski
  2015-08-09 16:38     ` Drew Adams
       [not found]   ` <mailman.8032.1439135226.904.help-gnu-emacs@gnu.org>
  1 sibling, 1 reply; 24+ messages in thread
From: Marcin Borkowski @ 2015-08-09 15:46 UTC (permalink / raw
  To: Help Gnu Emacs mailing list


On 2015-08-09, at 17:28, Drew Adams <drew.adams@oracle.com> 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.)
>
> Yes.  `equal' requires symbols to have the same name, value,
> function definition, and plist, and to be interned in the same
> obarray.  They need to be the same Lisp object (a symbol).
>
> In sum: they need to be `eq'.

Do I get it right that for two symbols to be `eq' it is enough for them
to have the same name and to be interned in the same obarray?

> Emacs Lisp doesn't have a spec (just its code, and some doc).
> But this is what the Common Lisp spec says about `equal' for
> symbols:
>
>  Returns true if x and y are structurally similar (isomorphic)
>  objects.  Objects are treated as follows by equal.
>
>  * Symbols, Numbers, and Characters
>    equal is true of two objects if they are symbols that are eq,
>                                             ^^^^^^^^^^^^^^^^^^^
>    if they are numbers that are eql, or if they are characters
>    that are eql.

Thanks,

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



^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: Are two symbols `equal' iff they are `eq'?
       [not found]   ` <mailman.8032.1439135226.904.help-gnu-emacs@gnu.org>
@ 2015-08-09 15:59     ` Stefan Monnier
  0 siblings, 0 replies; 24+ messages in thread
From: Stefan Monnier @ 2015-08-09 15:59 UTC (permalink / raw
  To: help-gnu-emacs

> Do I get it right that for two symbols to be `eq' it is enough for them
> to have the same name and to be interned in the same obarray?

If they're interned, then that's pretty much true, but symbols aren't
all interned.


        Stefan


PS: And then of course, there are major ugly hacks like:

(let* ((ob (make-vector 10 nil))
       (s1 (intern "a" ob))
       (s2 (intern "b" ob)))
  (setf (aref (symbol-name s1) 0) ?b)
  (and (equal (symbol-name s1) (symbol-name s2))
       (not (equal s1 s2))))


^ permalink raw reply	[flat|nested] 24+ messages in thread

* RE: Are two symbols `equal' iff they are `eq'?
  2015-08-09 15:46   ` Marcin Borkowski
@ 2015-08-09 16:38     ` Drew Adams
  0 siblings, 0 replies; 24+ messages in thread
From: Drew Adams @ 2015-08-09 16:38 UTC (permalink / raw
  To: Marcin Borkowski, Help Gnu Emacs mailing list

> Do I get it right that for two symbols to be `eq' it is enough for
> them to have the same name and to be interned in the same obarray?

Yes.  Symbols are uniquely named in an obarray - there is only 
one interned symbol with any given name.  That's why `intern' and
`intern-soft' work, to give you _the_ symbol with the given name.

Note that you can create any number of uninterned symbols with
the same name, just as you can create different symbols with
the same name but interned in different obarrays.



^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: Are two symbols `equal' iff they are `eq'?
  2015-08-09 15:45             ` Marcin Borkowski
@ 2015-08-09 18:19               ` Eli Zaretskii
  2015-08-09 19:41                 ` Marcin Borkowski
  2015-08-10 15:26               ` Nicolas Richard
  1 sibling, 1 reply; 24+ messages in thread
From: Eli Zaretskii @ 2015-08-09 18:19 UTC (permalink / raw
  To: help-gnu-emacs

> From: Marcin Borkowski <mbork@mbork.pl>
> Date: Sun, 09 Aug 2015 17:45:31 +0200
> 
> >> >From the capitalization I would guess that QUIT is a C macro.  From its
> >> name I would guess that anything after it is irrelevant;-).  Well,
> >> joking aside, I found its definition in the source; do I get it right
> >> that it quits if something like C-g happens?
> >
> > Yes.
> >
> >> If yes, I'd be curious why it is here.
> >
> > To allow the user to interrupt a (potentially) long operation.
> 
> That's obvious, I just wondered why at this point.

Because that point is traversed every recursion, so we check for C-g
on each "iteration", so to say.

> >> Apart from that, it seems that I was right: `equal' for
> >> symbols just calls `eq' (C EQ, not Lisp eq, to be more precise).
> >
> > What else could it possibly do?
> 
> It could e.g. compare the string representation, so two symbols with the
> same name but in different obarrays, or one interned and the other not,
> could be equal but not eq.

I'm sure you understand how all of those would make no sense as
"equality" of any kind.

> (I'm not sure whether this would be useful, though - just a
> thought.)

If it won't be useful, why would someone do it?



^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: Are two symbols `equal' iff they are `eq'?
  2015-08-09 18:19               ` Eli Zaretskii
@ 2015-08-09 19:41                 ` Marcin Borkowski
  0 siblings, 0 replies; 24+ messages in thread
From: Marcin Borkowski @ 2015-08-09 19:41 UTC (permalink / raw
  To: help-gnu-emacs


On 2015-08-09, at 20:19, Eli Zaretskii <eliz@gnu.org> wrote:

>> From: Marcin Borkowski <mbork@mbork.pl>
>> Date: Sun, 09 Aug 2015 17:45:31 +0200
>> 
>> >> >From the capitalization I would guess that QUIT is a C macro.  From its
>> >> name I would guess that anything after it is irrelevant;-).  Well,
>> >> joking aside, I found its definition in the source; do I get it right
>> >> that it quits if something like C-g happens?
>> >
>> > Yes.
>> >
>> >> If yes, I'd be curious why it is here.
>> >
>> > To allow the user to interrupt a (potentially) long operation.
>> 
>> That's obvious, I just wondered why at this point.
>
> Because that point is traversed every recursion, so we check for C-g
> on each "iteration", so to say.

Ah, I see.  That does make sense.  Thanks!

>> >> Apart from that, it seems that I was right: `equal' for
>> >> symbols just calls `eq' (C EQ, not Lisp eq, to be more precise).
>> >
>> > What else could it possibly do?
>> 
>> It could e.g. compare the string representation, so two symbols with the
>> same name but in different obarrays, or one interned and the other not,
>> could be equal but not eq.
>
> I'm sure you understand how all of those would make no sense as
> "equality" of any kind.

Frankly, I don't.  I don't really have enough experience with the very
ideas of a "symbol", of "interning" and of an "obarray" (in particular,
having many of them) to see this.  I guess when I learn more Lisp (maybe
Common Lisp?), I'll see this.  But I believe you, and this is enough for
me now - I'll just try to keep that issue in my mind during my further
studies, and maybe I'll get it some day.  I'm not in a hurry, you
know;-).

>> (I'm not sure whether this would be useful, though - just a
>> thought.)
>
> If it won't be useful, why would someone do it?

If not, then not.  I agree.

Best,

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



^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: Are two symbols `equal' iff they are `eq'?
  2015-08-09 15:45             ` Marcin Borkowski
  2015-08-09 18:19               ` Eli Zaretskii
@ 2015-08-10 15:26               ` Nicolas Richard
  1 sibling, 0 replies; 24+ messages in thread
From: Nicolas Richard @ 2015-08-10 15:26 UTC (permalink / raw
  To: Marcin Borkowski; +Cc: help-gnu-emacs

Marcin Borkowski <mbork@mbork.pl> writes:
> On 2015-08-09, at 17:19, Eli Zaretskii <eliz@gnu.org> wrote:
>>> From: Marcin Borkowski <mbork@mbork.pl>
>>> Apart from that, it seems that I was right: `equal' for
>>> symbols just calls `eq' (C EQ, not Lisp eq, to be more precise).
>>
>> What else could it possibly do?
>
> It could e.g. compare the string representation,

FWIW, I think `string=` does that.

-- 
Nico.



^ permalink raw reply	[flat|nested] 24+ messages in thread

end of thread, other threads:[~2015-08-10 15:26 UTC | newest]

Thread overview: 24+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <mailman.7993.1439079676.904.help-gnu-emacs@gnu.org>
2015-08-09  0:31 ` Are two symbols `equal' iff they are `eq'? Joost Kremers
2015-08-09  5:16   ` Ian Zimmerman
2015-08-09  7:30     ` Marcin Borkowski
2015-08-09 14:05       ` Michael Heerdegen
2015-08-09 15:10         ` Marcin Borkowski
2015-08-09 15:19           ` Eli Zaretskii
2015-08-09 15:45             ` Marcin Borkowski
2015-08-09 18:19               ` Eli Zaretskii
2015-08-09 19:41                 ` Marcin Borkowski
2015-08-10 15:26               ` Nicolas Richard
     [not found]   ` <mailman.8007.1439097407.904.help-gnu-emacs@gnu.org>
2015-08-09  5:21     ` Rusi
2015-08-09  5:33       ` Ian Zimmerman
2015-08-09  7:42   ` Marcin Borkowski
2015-08-09 14:03     ` Michael Heerdegen
2015-08-09 14:42       ` Marcin Borkowski
2015-08-09 14:47         ` Michael Heerdegen
     [not found]   ` <mailman.8011.1439106166.904.help-gnu-emacs@gnu.org>
2015-08-09 15:38     ` Joost Kremers
2015-08-09  0:20 Marcin Borkowski
2015-08-09  1:52 ` Emanuel Berg
2015-08-09  7:44   ` Marcin Borkowski
2015-08-09 15:28 ` Drew Adams
2015-08-09 15:46   ` Marcin Borkowski
2015-08-09 16:38     ` Drew Adams
     [not found]   ` <mailman.8032.1439135226.904.help-gnu-emacs@gnu.org>
2015-08-09 15:59     ` Stefan Monnier

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.