Do symbols need to be EQ?

Anton Vodonosov avodonosov at yandex.ru
Fri Jul 3 07:30:38 UTC 2015


EQ just checks object identity.

Symbol names, like CL-USER::FOO are a way to refer symbol objects
using packages machinery. If we manipulate packages then dereferencing
the name CL-USER::FOO may return different object, and they would not be EQ.

Yes, INTERN gives us ability to use CL-USER::FOO as a reference to
exactly the same symbol object, unless someone destructed the symbol name/object mapping.

That's what I rely to and don't expect the standard to provide
any more guarantees.

Best regards,
- Anton

03.07.2015, 10:17, "Anton Vodonosov" <avodonosov at yandex.ru>:
> I think the most confusing part is what you mean by "same" symbols.
>
> 03.07.2015, 10:10, "Edi Weitz" <edi at weitz.de>:
>>  Just out of curiosity and without any relevance in practise:
>>
>>  Is there one place in the standard where it is explicitly said that
>>  two symbols which are the "same" symbol must be "identical"? I know
>>  that there are a couple of examples where this is implied, but
>>  formally the examples aren't part of the standard, right?
>>
>>  The EQ dictionary entry for example shows this example:
>>
>>    (eq 'a 'a) => true
>>
>>  and then it continues with this note (emphasis mine): "Symbols that
>>  print the same USUALLY are EQ to each other because of the use of the
>>  INTERN function."
>>
>>  And the entry for INTERN is actually the closest I could find in terms
>>  of clarification because it says that if a symbol of a specified name
>>  is already accessible, _IT_ is returned -- which sounds like object
>>  identity to me.
>>
>>  But how does this fit into the picture?
>>
>>    CL-USER 1 > (defparameter *s* 'foo)
>>    *S*
>>    CL-USER 2 > (unintern 'foo)
>>    T
>>    CL-USER 3 > (defparameter *s2* 'foo)
>>    *S2*
>>    CL-USER 4 > (eq *s* *s2*)
>>    NIL
>>
>>  *S* has lost its home package and is thus not EQ to *S2*, sure, but
>>  how do we explain this in terms of object identity? Has the UNINTERN
>>  operation changed the identity of *S* which once was the one and only
>>  CL-USER::FOO but can't be anymore because this role is now occupied by
>>  *S2*?
>>
>>  Did I miss some clarifying words in the standard? Did I just manage
>>  to confuse myself?
>>
>>  Thanks,
>>  Edi.
>>
>>  PS: The UNINTERN entry warns about side effects which could harm
>>  consistency, so maybe this is what they meant?



More information about the pro mailing list