Symbols, Protocols, Frames, and Versioning

Tab Atkins Jr. jackalmage at gmail.com
Thu Oct 4 10:54:55 PDT 2012


On Thu, Oct 4, 2012 at 8:27 AM, Brendan Eich <brendan at mozilla.com> 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?

I like it!

Yes, I think it's better than just using 'iterator'.  Pushing these
things into a separate namespace, as this effectively does, avoids
most of the accidental collisions.  It also lets you do
collision-avoidance via ad hoc namespacing without paying the
long-name tax more than once (when you first create the Symbol).

It might be useful to expose this functionality with a more obvious
name, to underscore that you lose the secrecy/unforgability.
Symbol.public()?

~TJ


More information about the es-discuss mailing list