From: Dave Howell Date: 2006-01-05T07:47:28+09:00 Subject: Re: On Symbols On Jan 4, 2006, at 14:06, Dave Howell wrote: > > On Dec 30, 2005, at 5:39, Devin Mullins wrote: > >> Hey, all you lurkers: >> >> Have any of the explanations in the thread (What is the difference >> between :foo and "foo" ?) helped you understand symbols? Gregory Brown's examples showing object IDs have provided some hints, although I now feel an awful lot like Alice: 'You are sad,' the Knight said in an anxious tone: 'let me sing you a song to comfort you.' 'Is it very long?' Alice asked, for she had heard a good deal of poetry that day. 'It's long,' said the Knight, 'but very, VERY beautiful. Everybody that hears me sing it--either it brings the TEARS into their eyes, or else--' 'Or else what?' said Alice, for the Knight had made a sudden pause. 'Or else it doesn't, you know. The name of the song is called "HADDOCKS' EYES."' 'Oh, that's the name of the song, is it?' Alice said, trying to feel interested. 'No, you don't understand,' the Knight said, looking a little vexed. 'That's what the name is CALLED. The name really IS "THE AGED AGED MAN."' 'Then I ought to have said "That's what the SONG is called"?' Alice corrected herself. 'No, you oughtn't: that's quite another thing! The SONG is called "WAYS AND MEANS": but that's only what it's CALLED, you know!' 'Well, what IS the song, then?' said Alice, who was by this time completely bewildered. 'I was coming to that,' the Knight said. So saying, he stopped his horse and let the reins fall on its neck: then, slowly beating time with one hand, and with a faint smile lighting up his gentle foolish face, as if he enjoyed the music of his song, he began. I'm developing the very strong suspicion that no explanation of symbols will get far unless it's part of a broader context that includes variables and references. dblack said: > a = "string" # a contains a reference to that string and Gregory provided examples that indicate something more complicated: the `a' above contains a reference to an object, created especially for that variable, that contains six characters. Doing it again with variable `b' gives you an identical twin. > a = 1 # a contains the actual (immediate) value 1 Except the example would seem to contradict this statement. `a' `b' and `c' do not contain actual anythings. They contain references to the same object, that object which is the value "1". Maybe. I guess it depends on what, exactly, the .object_id method returns, or on what "actual" or "immediate" means. It would appear it means something much less immediate than I'd expect. "Named number" is beginning to make sense, to the degree that it's now clear there's some kind of serious difference between strings and (some kinds of?) numbers in Ruby. On the other hand, there's still some serious ambiguity, because Gregory's numbers and strings were put into variables, but the symbols weren't stored in variables. What I need to figure out is how does a symbol differ from a string literal, numeric literal, or variable, not how it differs from a string or number IN a variable. Onward..... Once again, a gentle reminder: please feel free to comment on the learning process I'm documenting if you like, but do NOT respond if you're going to try to explain more about symbols and whatnot. Thanks!