Symbols, Protocols, Frames, and Versioning
brendan at mozilla.com
Thu Oct 4 10:09:25 PDT 2012
Allen Wirfs-Brock wrote:
> presumably, looking up "iterator" in a registry of string/symbol key
> value pairs. Creating a new entry if one isn't present, and
> regardless returning the symbol value associated with the string.
> public @iterator = Symbol('iterator');
No, I wrote Symbol.intern('iterator') on purpose. What you wrote just
makes a unique symbol with debugging/diagnostics string associated with it.
> conceptually could just as easily be expressed as:
> public @iterator = RegistryOfWellKnownSymbols.lookup('iterator');
Yes, Symbol.intern would be just like that -- but shorter and standard
if we choose to do it.
> On Oct 4, 2012, at 10:01 AM, Kevin Smith wrote:
>> Dave Herman mentioned another idea: intern'ing strings as
>> symbols. You'd lose uniqueness but avoid colliding with any
>> string. So
>> public @iterator = Symbol.intern('iterator');
>> Is this much better than just using 'iterator' or dunder-iterator?
>> Apologies, but what would interning a string as a symbol mean?
>> es-discuss mailing list
>> es-discuss at mozilla.org <mailto:es-discuss at mozilla.org>
More information about the es-discuss