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

Brendan Eich brendan at
Sun Jan 22 20:58:28 PST 2012

> Herby Vojčík <mailto:herby at>
> January 22, 2012 12:34 PM
> Brendan Eich wrote:
>> I suspect your very complicated translation with __prvTable__ etc. is
>> intended to hoist private somehow, once per declaration in source rather
>> than once per evaluation of declaration. That's too restrictive, since
> Exactly. By design.

For classes, we have agreed on class-private, rather than 
instance-private, instance variables. However you don't need such a 
complex desugaring for classes, and "private x;" not in a class should 
be evaluated, not hoisted into singleton-hood somehow.

   class Point { ... private x, y; ... } // ignore details of whether in 
constructor or class body

should desugar roughly to

   let Point = do { private x, y; class Point { ... ... } };

so as to achieve the class-private instance variable semantics wanted. 
This does suggest that putting the private declarations in constructor 
is a mistake, since they would seem to be generated once per 
construction (instance), not once per class (as class-private wants).


More information about the es-discuss mailing list