shortcuts for defining block-local private names, plays nicely with @foo syntax

Tab Atkins Jr. jackalmage at gmail.com
Sun Jan 22 23:44:05 PST 2012


On Sun, Jan 22, 2012 at 11:25 PM, Brendan Eich <brendan at mozilla.org> wrote:
>> Tab Atkins Jr. <mailto:jackalmage at gmail.com>
>> January 22, 2012 7:36 PM
>>
>> myCoolObject.prototype[Iterator.getIterator] = function(){...}
>> Using @ for access, would "myCoolObject.prototype. at Iterator.getIterator =
>> function(){...}" work, or would that attempt to retrieve a property using
>> "Iterator" as a Name, then retrieve the "getIterator" property of that?
>
>
> To quote D. Duck, "pronoun trouble". By your final "that", you mean the
> iterator Name instance? If so, no way -- that doesn't make any sense. A dot
> operator in JS accesses a property value, not key.
>
> So rest assured: the former.

Allow me to be clearer.

Given "foo.bar = new Name();", is "baz. at foo.bar" equivalent to
"baz[foo.bar]" or "baz[foo].bar"?  Normal property-access semantics
would give the latter.  If so, then we need to preserve the [] form
for use with private names in both the "baz[foo.bar]" form and the
"{[foo.bar]: true}" form, unless we find it acceptable for authors to
be forced to use a local variable to store the Name every time.

~TJ


More information about the es-discuss mailing list