shortcut for private(this)

Brendan Eich brendan at
Fri Jan 20 10:27:19 PST 2012

Let's not bikeshed class private syntax just yet. I mean, we could 
(es-discuss, right?) but I don't think it is productive.

And again, we do not want a reified "private state object", so private 
could not be a free expression. This also hurts private(other).weight -- 
'weight' is not an identifier in a "private state object", it has to be 
a private name object binding. Therefore we should avoid any syntax 
suggesting a first-class reflection of a private state object.

This is why @foo for private name object bound to lexical identifier foo 
has been proposed. It also has the benefits of being shorter and 
matching some other languages near to JS.


> Herby Vojčík <mailto:herby at>
> January 19, 2012 9:58 AM
> Hello,
> I think private itself could be used as a shortcut to private(this). 
> It may look for example like this:
> class Foo {
>   ...
>   leq(other) {
>     return private.weight <= private(other).weight;
>   }
>   ...
> }
> It is not unprecedented, there already is a keyword that represents 
> this as well as other object in a strange manner (super). So private 
> can also be such a word.
> I don't see any grammatical/parsing/syntanctic problems with this for 
> the moment. Maybe you find one.
> Herby
> P.S.: Since it is very similar (and works everywhere, not 
> only in constructor), it may be though of to remove 'private foo = 
> bar;' in constructor in favour of ' = bar;'. But it is only 
> sort of afterthought. Also, 'public baz = moo;' could then be changed 
> by simple 'this.baz = moo;' to make code in constructor more akin to 
> code used everywhere else.
> _______________________________________________
> es-discuss mailing list
> es-discuss at

More information about the es-discuss mailing list