getter & setter for private objects
brendan at mozilla.com
Mon Nov 2 15:15:28 PST 2009
On Nov 2, 2009, at 3:05 PM, memolus at googlemail.com wrote:
> 2009/11/2 Brendan Eich <brendan at mozilla.com>:
>> Defining accessors on an activation object is nasty,
>> If you want private getters and setters, you can put them in an
>> object denoted by a private var:
> So you prefer ugly solutions, because the others are nasty?
I don't prefer any of this! You do, but I still am not sure why.
Private variables I understand, and those are doable using closures
(possibly other ways in Harmony).
But private variables defined by var (or let) are not private getters
and setters -- why do you need the latter?
>> The upshot for memolus is that with is already a deoptimizer that
>> non-lexical names onto the scope chain. These can be gettters and
>> and have arbitrary effects. My point remains that adding getters
>> and setters
>> to activations, which are modeled lexically in the absence of eval,
>> strict mode in ES5, and under other such conditions, is a non-
> I didn't get how to use "with" in order to use private objects
> (non-lexical names onto the scope chain). Just ignore my example if it
> tries to add getter and setter to already activated objects. You don't
> have to implement it this way.
How then can they be implemented? Not by interposing a with object,
since that changes |this| binding....
I suggest you try to state concrete use-case examples first, in order
to write down requirements.
More information about the es-discuss