Brendan Eich <mailto:bren...@mozilla.org>
January 23, 2012 11:08 AM

We run into this kind of trade-off all the time, but the fact is that right now, dot and brackets are equivalent for properties named by strings that match the IdentifierName lexical production. This isn't the case for private names, of course -- by design: no string equivalent so no dot.

This was prolog, but then I edited too much and may have been unclear:

However it does not follow that a first-class private name object value cannot be used in square brackets to access a property it names.

This is about http://wiki.ecmascript.org/doku.php?id=harmony:private_name_objects -- an accepted proposal in Harmony and extremely likely to be going into ES6.

If we must future-proof, then it follows that .@ and even .@() must be part of private name objects. If everyone agrees, then we have a decision to make.

I don't think everyone agrees on future-proofing for

http://wiki.ecmascript.org/doku.php?id=strawman:object_model_reformation

yet, so I wonder if we'll all agree to add.@ etc. to private_name_objects. That got into Harmony by avoiding new syntax. We do not want to go in a circle here (rather, a progress-making spiral ;-).

/be

/be
_______________________________________________
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss

Allen Wirfs-Brock <mailto:al...@wirfs-brock.com>
January 23, 2012 11:01 AM

Below...
Brendan Eich <bren...@mozilla.org> wrote:
> Allen Wirfs-Brock <mailto:al...@wirfs-brock.com>
> January 23, 2012 8:43 AM
> On Jan 22, 2012, at 7:36 PM, Tab Atkins Jr. wrote:
>
?..
>
> const getIterator = Iterator.getIterator;
> myCoolObject.prototype.@getIterator = function() {...}

Why wouldn't myCoolObject.prototype[iterator.getIterator] work?

/be

It would, for now. But, I think you gave the reason for avoiding this pattern in another reply. If we ever want to adopt my Reformed Object Model proposal then we should avoid using [ ] for private name property access. lt would actually still work fine for objects with default [ ] behavior but not for collection objects that redefine [ ] access.

Before encouraging a new pattern like obj[Iterator.GetIterator] we should think about its future-proofing implicationa.

Allen
_______________________________________________
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to