Agreeing on user-defined unique symbols?
Tab Atkins Jr.
jackalmage at gmail.com
Thu Aug 1 11:08:40 PDT 2013
On Wed, Jul 31, 2013 at 7:11 PM, Brendan Eich <brendan at mozilla.com> wrote:
>> On Wed, Jul 31, 2013 at 5:34 PM, Brendan Eich<brendan at mozilla.com> wrote:
>>> You say either and I say either,
>>> You say neither and I say neither
>>> Either, either neither, neither
>>> Let's call the whole thing off.
>>> You like potato and I like potahto
>>> You like tomato and I like tomahto
>>> Potato, potahto, tomato, tomahto.
>>> Let's call the whole thing off
>>> - Ira Gershwin
>>> I feel like calling off symbols when we have string-keyed interning
>>> and three namespaces and bears, oh my.
> I'm going to concede you have a path-dependent point, but spend some time on
> my "Realm, schmealm!" thread in hope of a simpler future.
If something interesting comes out of there, great!
In the meantime, though the magic words "three namespaces" sounds
really complicated, it's not. ^_^ At least, it's less complicated
than symbols - you could implement it by adding two bits to Strings,
one to track whether they're a symbol string, and one to track whether
they're UA-created (and thus unforgeable, because user code can't set
that bit). Messing with properties then depends on string contents +
the two bits, rather than just contents as today.
Or you could do a new object that's a wrapper around strings, if those
two bits would be annoying to add to all strings. But still, it's a
really simple thing, because there's no special lookup or registry or
anything like "namespace" usually implies. They're just two more sets
of strings prevented from colliding with each other or "normal"
Also, note that the interning table that Mark mentions isn't required
at all, unless you want the possibility of real symbols (and just
allow collision in the "registry"). Even then, you can avoid this by
producing either a "real symbol" (guaranteed unique) or a "symbol
string", based on whether it's constructed directly or obtained from
the interning process. The "registry" would in this scenario just be
a sham, a convenient fiction we use to make people think of
More information about the es-discuss