From: David Masover Date: 2009-03-30T23:00:21+09:00 Subject: Re: Symbols garbage collector in Ruby1.9, fixed? On Monday 30 March 2009 07:48:16 James Gray wrote: > Dave Thomas seems to have thought this was going away: > > http://pragdave.blogs.pragprog.com/pragdave/2008/05/ruby-symbols-in.html That article looks like pure speculation. Alright, yes, #to_i and #id2name and similar are gone. That makes sense -- encapsulate things the average user really doesn't need. Theoretically, these could allow Symbols to be implemented in the heap, if needed. Or it would allow them to be implemented in some way that looks nothing like the current concept of an integer. However, the purpose of symbols, I would think, remains the same. And given the purpose of symbols, and the dynamic nature of Ruby (it has eval!), there's really no way you could ever garbage collect symbols. You could implement symbols as immutable strings on the heap, and do string comparisons between them, but that would defeat the purpose of symbols, at least in every program I've ever wrote -- to avoid string comparisons, and to be generally much faster than strings. And for that matter, if you really, really want to be digging around at that low level, you still can: irb(main):001:0> :foo.object_id => 351848 irb(main):002:0> ObjectSpace._id2ref 351848 => :foo