Dean Landolt (2013-07-31T16:21:11.000Z)
domenic at domenicdenicola.com (2013-08-02T20:47:04.201Z)
On Wed, Jul 31, 2013 at 10:50 AM, Mark S. Miller <erights at google.com> wrote: > In thinking about this, I become ever more puzzled about the versioning > and inter-realm problems for user-defined unique symbols -- I think it may > be a train wreck. Scenario: Library W version 1.1 defines and uses a unique > symbol @foo which is loaded into realm A. Library W version 1.2 purposely > intends to continue to define and use the "same" unique symbol @foo, so > that W1.2 code can successfully handle instances of W1.1 code. Library W1.2 > is loaded into realm B. The two realms come into contact, and objects from > the two W's come into contact. *How did they both coordinate to define > and use the same @foo symbol?* I responded in separate thread, but I'd add that this problem exists regardless of the mechanism chosen for doing unique. It's not a problem of symbols but of intrinsic object identity. This is why I believe modeling symbols as stateless frozen objects is most sensible and correct thing. > That's why you refer to them symbolically. Just like we write Math.PI in good code, rather than 3.14159... Agreed -- I was mostly joking. But there's a reason the proposal called for a string prefix -- they will be reflected in the raw. Unlike Math.PI, this raw value is meaningless. > This is the enumerability issue which I already acknowledged, right? Is there anything more to this? I was responding directly to Kevin's comment: > That leaves default non-enumerability. Consider the fact that object > literal methods are enumerable. Why should choosing a "unique name" as > opposed to an identifier for a method have any bearing on enumerability? I was pointing out the very real hazard that exists in code which wouldn't be considered objectively bad. To be explicit, I'm claiming that for/in over object keys can be the Right Thing in cases where you want all enumerable keys up through the prototype. If unique symbols aren't enumerable *and* the platform demands any of them on Object.prototype this will introduce subtle run-time breakages at least as badly as "null" typeof. Even if es6 avoids them on Object.prototype who's to say they won't be needed in later versions? This will bite eventually.