About private names

Brendan Eich brendan at mozilla.com
Mon Mar 21 12:03:17 PDT 2011

On Mar 21, 2011, at 11:29 AM, Andrew Dupont wrote:

> On Mar 21, 2011, at 11:14 AM, Brendan Eich wrote:
>> Hi Andrew, thanks for the good thinking on this thread. I'm not cherry-picking here, but I wanted to reply to the specific sentence ending "entire lexical scope".
>> The Harmony top-level scope (no global object!) will be big and it may even grow by (non-colliding) extension, sure. Hence Dave's thought of not allowing private there.
>> Anyway, I wanted to check this (what I took to be your own experience-based) weighting of search space sizes.
> This is a good point — I'm imagining lexical scopes that, at their largest, can span the entirety of a very large library like Prototype or jQuery.

They can be big (so can Java class sources). But they can be pretty small, too. Programmers get to narrow private name scope via explicit blocks, and I wasn't sure this was clear.

> Not allowing private in the top-level scope would help a bit (at the cost of hindering the "Conflict-Free Object Extension Using Private Names" use case),

Not sure that is hindered much. Private names can be "consumed" as well as "produced" within block scope, too.

> but any lexical scope can grow to a staggering size.

This argument goes against Java class sources, too, so to have a fair debate we should either refine it somehow, or exclude it.

> On Mar 21, 2011, at 11:14 AM, Brendan Eich wrote:
>> Is a lexical scope bigger and harder to search than two or more class files in Java? Ignoring IDEs, this seems to suggest lexical scopes tend to be "big". Is this based on your experience with JS blocks (not function bodies or global scopes) today?
> Until now, yes, I have been imagining a function body as an example of a lexical scope. Why are you excluding it?

Only to point out that private is block-scoped, like let and const (and function in block). Sure, you can use function bodies too, but you won't have to in Harmony. Currently it's all you have.


More information about the es-discuss mailing list