From: Sigurd Date: 2012-02-10T23:37:06+09:00 Subject: Re: Symbol garbage collection --Apple-Mail=_85E3597E-38DE-44EF-984B-3498ED7DF505 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=iso-8859-1 Hi, Ruby store all object, method and variable names as a symbols. That's = why symbol GC might be dangerous. The only thing i'm not clear about is the rb_gc_mark_symbols method that = is implemented in parse.y and is called for every GC round. Can someone explain what's its purpose? On Feb 10, 2012, at 3:52 PM, Jes=FAs Gabriel y Gal=E1n wrote: > On Fri, Feb 10, 2012 at 1:48 PM, Robert Klemme > wrote: >> 2012/2/10 Jes=FAs Gabriel y Gal=E1n : >>> 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. >>>>=20 >>>> 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. >>>=20 >>> 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? >>=20 >> 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. >>=20 >>> 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. >>=20 >> 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. >=20 > Makes sense, thanks. >=20 > Jesus. >=20 --Apple-Mail=_85E3597E-38DE-44EF-984B-3498ED7DF505--