Look Ma, no "this" (was: ECMAScript Harmony)

Brendan Eich brendan at mozilla.org
Sun Aug 24 18:05:30 PDT 2008

On Aug 24, 2008, at 4:09 PM, Mark S. Miller wrote:

> This gives
> instance-private rather than class-private variables, which is the
> safer default for a dynamic language. The new objects-as-closure sugar
> also gives instance-private encapsulation, and without proposing any
> new semantic state. I think it is better in all ways.

This is not settled in committee. Instance-private as in Smalltalk  
requires writing getters and setters, and at least some kind of  
branding or sealer/unsealer pair test so that Point methods can even  
tell they're dealing with another Point instance.

Many more conventional and nearby languages support class-private  
variables, where Point methods could see any instance's privates, not  
just its own.

We need to sort this out, but no rush. Your position may not be clear  
to the list, though, so I thought I'd elaborate slightly. The  
consequence of using lexical scope for private variables is that they  
are instance-private. It's a nice hat trick: privacy, higher  
integrity, and semantic reuse all in one.

I'm still open to it, but we have the generative Name idea as an  
alternative way to make private names, which could be class-private  
or even "friend" among classes in the same lexical scope.

Others on this list should comment on class-private vs. instance- 


More information about the Es-discuss mailing list