From: joswig@... Date: 2007-03-10T01:10:07+09:00 Subject: Re: Paul Graham explains Ruby symbols On Mar 9, 3:13 pm, "Rick DeNatale" wrote: > On 3/8/07, jos...@corporate-world.lisp.de > > > > wrote: > > On Mar 7, 6:17 pm, "Rick DeNatale" wrote: > > > On 3/6/07, Luciano Ramalho wrote: > > > > > Paul Graham offers this excellent explanation for the symbol type: > > > > > "Symbols are effectively pointers to strings stored in a hash table. > > > > So you can test equality by comparing a pointer, instead of comparing > > > > each character." [1] > > > > > Of course, he's talking about symbols inLisp, but what he says > > > > applies equally well to Ruby and Smalltalk. > > > > I find this a little too implementation-centric a description. > > > > The key aspect of symbols is that two symbols are identical if they are equal. > > > The fact that there may (or may not be) a hash table used to ensure > > > this is irelevant. > > > > And that description really misses the boat as far asLispis > > > concerned.Lispsymbols aren't strings, they are really names to which > > > three (separate) things can be bound, a value (which can be anyLisp > > > object), a function, and a property list. Actually the name is also > > > one of the slots in a symbol. > > > Actually it's five in Common Lisp: Value, Function, Name, Property > > List, Package. > > > > Note that inLispthe value of a Symbol is separate from it's name, > > > and two Symbols can have the same value, they just can't have the same > > > name. > > > No, that's wrong. Two different symbols can have the same name in > > Common Lisp. > > > CL-USER 30 > (eq '#:foo '#:foo) > > NIL > > > CL-USER 31 > (symbolp '#:foo) > > T > > > CL-USER 32 > (symbol-name '#:foo) > > "FOO" > > > > So inLispa symbol is more like an entry in the table of global names. > > > No. In Lisp a symbol is a data structure with above five (virtual) > > slots. > > Symbols can exist without a 'table of names'. These 'table of names' > > are called packages. A symbol can belong to a package. You can then > > lookup the symbol via the package by its name. Again a symbol > > can exist without being interned in a package > > Well, I never claimed to be a Lisp expert, the last time I used Lisp > seriously it was Lisp 1.5. Lisp 1.5 is not really in use anymore. > > On the other hand, the author of the originally referenced > 'explanation of symbols' seemed to be basing his description on his > knowledge of Lisp. > > Given all the other differences pointed out byjoswig, I think that my > original contention that: > > > > Symbols in Ruby and Smalltalk are more alike than Symbols inLisp. > > seems to be more true than ever. > Symbols in Ruby and Smalltalk are like keyword symbols in Common Lisp. Keyword symbols are symbols in the package KEYWORD and they have themselves as value and they are unique. > -- > Rick DeNatale > > My blog on Rubyhttp://talklikeaduck.denhaven2.com/