allen at wirfs-brock.com
Wed May 18 09:27:18 PDT 2011
On May 18, 2011, at 4:42 AM, Erik Corry wrote:
> 2011/5/18 Andreas Rossberg <rossberg at google.com>:
>> Separating out the functionality of abstract names certainly is a good idea.
>> But is there any reason to make it a method of Object? In essence,
>> private names form a new primitive type, so there should be a separate
>> global object or module for them. Assuming for a minute it was called
>> Name (which clearly is a suboptimal choice), then you'd rather invoke
>> Name.create(), or perhaps simply Name() (by analogy with calling
>> String(v) to create primitive strings, although I'm not sure I like
>> the notational abuse behind it).
> It would be nice to do Name("foo") or PrivateName("foo") so that the
> debugger has some name to use when displaying objects with private
> fields. Alternatively, I suppose the debugger could guess the name
> like it does currently for Foo.prototype.myFunc = function() .... This
> has the disadvantage that a library that uses unique strings to
> simulate some of the features of private names on older browsers would
> not be able to give the unique names a meaningful prefix.
As Dave mentioned earlier in this thread he and I are still working on a unified proposal. Luke mentioned my latest working draft that tries to address some of the issue mentioned above. It is at http://wiki.ecmascript.org/doku.php?id=strawman:unique_string_values. Note however, that this iteration is not necessarily what we will end up proposing.
In general, it is a good idea to avoid new global names that aren't going to be in modules. In particular, there is no particular reason these factory methods shouldn't be visible via the Harmony "ES5" global object. In that case hanging them off an existing constructor carries less risk of collisions (but not no risk) with user defined name. "Name" seems like it might be a particularly risky global to grab. Luke suggested hanging them off Object and in my working draft I suggest String. Either is probably safer than adding new globals.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the es-discuss