> This would seem to be a fundamental conflict between using [ ] to access 
> private properties and using [ ] as a special collection element accessor 
> syntax.  You might take this as problem with using [ ] as a collection 
> accessor or as a discovering that using [ ] as a private property access or 
> is not very future proof.  I think that the long term appeal of using [ ] for 
> collections is compelling enough that we should re-consider the private name 
> usage and define perhaps define new syntax/semantics for private name access. 
> Here is a first cut:
> 
>  MemberExpression : MemberExpression @ Identifier
> 
> where the semantics is that Identifier is evaluated as a variable reference 
> and its value is used as a private name keyed property lookup. Throws if the 
> value of the variable is not a private name object.  We would then write my 
> example as:
> 
> import {collectionGetter, collectionSetter} from "@metaCollections";
> content = Name.create();
> export function StringKeyedMap() {
>    this@content = Object.create(null);  //note content object is a "normal 
> object" and [ ] on it does regular property access
>    this@collectionGetter = function(k) {return this@content [k]};
>    this@collectionSetter  = function(k,v) {this@content [k]=v;};
>    this.size = function() {Object.getOwnPropertyNames(this@content ).length}; 
>  //I'm lazy
>    this.has = function(k) {return {}.hasOwnProperty.call(this@content,k};
>    this.delete = function(k) {return delete this@content [k]}
> }


I agree 100% percent with the observations, but not with the solution.

Shouldn’t this be done the other way around, by introducing a new way of 
accessing map elements? For example:
     map@[key]
     map.[key]

Then we can continue to use . and [] to access properties and use @[] to access 
data structure elements. I wouldn’t like the asymmetry introduced by using [] 
for the latter task.

Axel

-- 
Dr. Axel Rauschmayer

[email protected]
twitter.com/rauschma

home: rauschma.de
blog: 2ality.com



_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to