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

Herby Vojčík herby at
Sat Jan 21 14:21:22 PST 2012

Brendan Eich wrote:
>> Herby Vojčík <mailto:herby at>
>> January 21, 2012 1:56 PM
>> Brendan Eich wrote:
>>> private foo;
>>> @foo = bar; // this-relative private foo
>>> return @foo === other. at foo;
>>> return {@foo: bar};
>> This helps a lot, but there still _is_ an
>> identifier foo having that private name in its value.
> This was not decided, as far as I know. There are two choices:
> 1. "private foo;" defines a lexical binding used to denote the private
> name object, as well as after @ to use it to access a property in an
> object.
> 2. Rather, the *only* places foo would be allowed after "private foo;"
> above are those after an @. IOW it would be fine to use "let foo = 42;"
> and "private foo;" without conflict. Some further syntax, a la the old
> proposal (obsoleted in terms of # now), would be required to
> reflect foo from lexical-to-the-right-of-@ space into a first-class
> private name object reference.

Oh. I favor 1. Inspired by latest notes and for(let...) I would see
     private foo;
desugared to
     let foo = _the_real_foo;
where _the_real_foo is defined somewhere at the module or program level 
such that it will not clash (hardwired private name or index to a table 
or whatever) and the rest is just reusing existing rules.

2. is too magical (for me).

> /be


More information about the es-discuss mailing list