From: Robert Klemme Date: 2012-02-10T21:48:04+09:00 Subject: Re: Symbol garbage collection 2012/2/10 Jesús Gabriel y Galán : > On Fri, Feb 10, 2012 at 11:07 AM, Robert Klemme > wrote: >> On Fri, Feb 10, 2012 at 8:28 AM, Dido Sevilla wrote: >>> I've always wondered why Ruby didn't do garbage collection of symbols, >>> when Lisp implementations here and there did so, and in fact they are >>> essential in macro programming because Lisp programs tend to create a >>> lot of unique symbols at runtime, especially in macro code, with such >>> contrivances as gensym in Scheme and Common Lisp and uniq in Arc. >> >> In Ruby the idea is rather to only use a fixed amount of Symbols in >> the program and use Strings for everything that changes often. > > I have a question about this rule of thumb: did this rule came to > existence precisely due to the fact that Symbols are not GCed, or was > it the other way around? I can't speak for Matz but from what I have gathered it was his very conscious design decision to have Symbols not GC'ed. > Maybe if Symbols' garbage collection wasn't a problem, that rule about > using them just in a limited and fixed amount would have never > existed. But without this distinction there is really no point in having String AND Symbol any more. A Symbol then would merely be a String which is frozen by default. I prefer the current situation because it makes much more sense in my opinion. With a symbol we denote a fixed identifier which is used in multiple locations of an application and with a String we denote arbitrary text content. Kind regards robert -- remember.guy do |as, often| as.you_can - without end http://blog.rubybestpractices.com/