From: Rick DeNatale Date: 2007-05-20T10:18:22+09:00 Subject: Re: Why was the "Symbol is a String"-idea dropped? On 5/19/07, Brian Candler wrote: > On Sat, May 19, 2007 at 08:28:24AM +0900, Rick DeNatale wrote: > > Ruby symbols are represented by a value computed by shifting the > > symbols integer representation left 8 bits and setting the low-order > > byte to 0xFF representation > > Perhaps it varies based on the Ruby version you're running; it's not like > that for me. > > irb(main):006:0> :foo.object_id.to_s(16) > => "39490e" > irb(main):007:0> RUBY_VERSION > => "1.8.4" You can't really see the internal bit representations from ruby, since they get manipulated before you see them. Much like the class of an object reported by ruby isn't the same as the object pointed to by its klass pointer at the C level. And even if you could, I was talking about the integer representation of the symbol, not the object_id. Not to say that this doesn't change between versions of ruby. Which is why it's carefully hidden from ruby code. > I think a weaker requirement than 'immediate' is needed. A symbol can quite > happily be a regular object; we just need to ensure that there is always > only one symbol for a particular symbol character sequence. Yes, I said that, but the key issue for the subject of the current thread is that Symbols aren't strings, they might have both a string representation and an integer representation, but then so do integers, and unlike Strings they have an essential requirement that equality implies identity which is an accidental property of integers in the range of Fixnum. -- Rick DeNatale My blog on Ruby http://talklikeaduck.denhaven2.com/