About private names

Brendan Eich brendan at mozilla.com
Mon Mar 21 09:14:22 PDT 2011


On Mar 20, 2011, at 11:30 PM, Andrew Dupont wrote:

> Java doesn't formalize this, you're right — but if I'm looking at `this.doSomething()` and wondering about its visibility, I can look in the class definition itself (to see if it's private) or in one of its superclasses (to see if it's protected). Java does formalize the locations of class files, so I know exactly where to look to get my answer. I think that's a far smaller area to have to search than an entire lexical scope.

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".

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?

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.

/be



More information about the es-discuss mailing list