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

Brendan Eich brendan at
Mon Jan 23 08:16:16 PST 2012

> Herby Vojčík <mailto:herby at>
> January 23, 2012 3:21 AM
> It can be solved this way:
>   module {
>     private foo, bar;
>     export function factory1 (args) { ... }
>     export function factory2 (args) { ... }
> but then foo and bar are known to the rest of the module. It was not 
> the premise.

There is nothing wrong with this solution, and everything right. If you 
want to keep foo and bar secret from other modules, you've done so. If 
you, for some reason, want to keep them secret from other contents of 
this module, use a block (but you'll have a harder time exporting -- 
export must come at module top level).

In any case, we're not making lexical singletons of private 
declarations, or of any declarations, however nested. That's simply a 
pigeon-hole problem for programmers who need the usual generativity JS 
declared forms (closures notably) provide. One bad precedent like this 
we fixed: ES3 regexp literals, which were singular per source literal.


More information about the es-discuss mailing list