New private names proposal

David-Sarah Hopwood david-sarah at
Wed Dec 22 19:49:01 PST 2010

On 2010-12-23 02:48, Brendan Eich wrote:
> On Dec 22, 2010, at 6:39 PM, David-Sarah Hopwood wrote:
>> Inspectors can bypass encapsulation regardless of the language spec.
> The Inspector is written in ES5. How does it bypass soft field strong encapsulation?

I meant, obviously, that inspectors in general can bypass encapsulation.

It is not clear to me that a usable inspector can be written purely in
ES5 using the reflection API. Doesn't an inspector have to be able to read
variables in any scope? Or maybe you mean by "inspector" something less
ambitious than I'm thinking of (but then it's not clear that it needs to
be able to read private fields, since it also can't read closed-over

>> As for "the ability to manipulate all properties of objects at a meta
>> level using reflection", strictly speaking that is still possible in the
>> soft fields proposal because soft fields are not properties. This is not
>> mere semantics; these fields are associated with the object, but it is
>> quite intentional that the object model views them as being stored on a
>> side table.
> The side table is in a closure environment only, not available to the
> inspector, which uses getOwnPropertyNames:
> function MyConstructor(x, ...) {
>    const mySoftField = SoftField();
>    mySoftField.set(this, x);
>    ...  // closures defined that use mySoftField
> }

OK, you're assuming that the inspector can't read state from closures.
So why does it matter that it can't read private fields, given that the
programmer would probably have used closures if they were not using
private fields?

>> Note that other methods of associating private state with an
>> object, such as closing over variables, do not allow that state to be
>> accessed by reflection on the object either.
> That's right, and that is exactly Allen's point in writing the rationale
> for weak encapsulation that he wrote, and my point in using the example
> ReliableFred relies upon: an inspector hosted in the browser written in ES5.

The constraint that the inspector be written in ES5 seems to be a purely
artificial one. All of the commonly used browsers have debugger extensions.

> Please reply in <500 words.

No, I'm not going to play your word-counting game.

David-Sarah Hopwood  ⚥

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 292 bytes
Desc: OpenPGP digital signature
URL: <>

More information about the es-discuss mailing list