Do symbols need to be EQ?

Martin Simmons martin at lispworks.com
Fri Jul 3 12:44:40 UTC 2015


>>>>> On Fri, 03 Jul 2015 12:15:32 +0300, Anton Vodonosov said:
> Envelope-From: avodonosov at yandex.by
> 
> A note about "philosophical problems" - if one wants to build
> a compact mental model, reasonable and consistent with all
> the Common Lisp properties, there probably may be more than
> one way to do so, and neither of possible models can be proven incorrect.
> 
> 03.07.2015, 11:16, "Anton Vodonosov" <avodonosov at yandex.ru>:
> > I personally don't think that name CL-USER::FOO anyhow represents
> > the "nature" of the symbol
> >
> > The same number may be referenced as #x20000000 and as 536870912.
> > It's just a way to refer the object, not the object itself.
> 
> I want to correct myself. Unlike numbers or any other objects,
> symbols _are_ about names, so we can say that the name CL-USER::FOO
> represents the "nature" of symbol.
> 
> I think Common Lisp wants to save memory and speedup comparison,
> so when we use the same name we get the same object, as implemented
> by INTERN (this trick even has name - the Flyweight pattern).
> 
> So, this is just an optimization trick, and UNITERN is a maintenance,
> system tool, not designed to express programs. We are encouraged to
> operate as if the symbol name means the same object.

I disagree about it being to save memory -- a CL symbol is an object with
mutable attributes, so identity is important.  Also, the identity of
uninterned symbols is just as important (e.g. for macros) as interned ones, so
finding symbols via packages (and the reader) is not fundamental to their
common use.

Packages are just a way to convert strings to symbols, which is useful when
they are obtained from files outside a running CL (e.g. via the reader/fasl
loader).

-- 
Martin Simmons
LispWorks Ltd
http://www.lispworks.com/



More information about the pro mailing list