On Mar 14, 2012, at 10:22 AM, Kevin Smith wrote:
> Hi Herby,
>
> Sorry, but to be clear I'm suggesting an alternate usage for @ consistent
> with CS. I'm also suggesting (somewhat subversively) that the proposed syntax
> obj.@privateName be dropped unless it can be proven that it provides
> quantifiable benefit over obj[privateName].
>
The reason to not require obj[primateName] as the primary syntax for accessing
private named properties is that it clashes with the goals of Object Model
Reformation proposal [1],
either immediately in ES6 (which some would like to see) or in a future
editions.
If obj[privateName] is the only way to access a private named property then
objects that redefine the semantics of [ ] such as ReformedArray[2] or
HTMLCollectionArray[3] could not easily also have private named properties,
which are essential for their implementation.
The obj.@privateName and defining private named properties in object literals
as {@privateName1: expr, @privateName2 () {}} permits private name properties
to easily co-exist linguistically with extensible obj[expr] semantics.
An essential part of the obj.@privateName semantics that the identifier
following the @ is evaluated as a variable reference to obtain the property key
value. That means that this.@foo only works if foo is defined as an in scope
variable (or const) binding. It is not equivalent to obj.foo which literally
uses "foo" as the property key. Under this semantic, @foo could be recognized
as an abbreviation for this.@foo but it would not mean the same thing as
this.foo. Of that reason, I think the abbreviation would problematic.
Extensible [ ] as proposed in [1] in conjunction with obj.@privateName adds new
expressability to the language. It lets you do things that couldn't be done
before. @name as a simple appreciation for this.name adds nothing new to the
language. Given a choice between the two, I would go with the enhanced
expressability.
Allen
[1] http://wiki.ecmascript.org/doku.php?id=strawman:object_model_reformation
[2]
http://wiki.ecmascript.org/doku.php?id=strawman:object_model_reformation#reformed_array
[3]
http://wiki.ecmascript.org/doku.php?id=strawman:object_model_reformation#rationalizing_dom_htmlcollections
> Thanks,
> kevin
> _______________________________________________
> es-discuss mailing list
> [email protected]
> https://mail.mozilla.org/listinfo/es-discuss
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss