Sorry, misunderstood the question.

Andrea Giammarchi wrote:


On Fri, Jan 20, 2012 at 2:24 AM, Herby Vojčík <[email protected]
<mailto:[email protected]>> wrote:


    Let the object created is foo. When calling foo.method(), it is
    accessing private(foo), not private(objectWithPrivates), since this
    is foo. "If yes" does not happen. Errors may happen since foo
    probably does not have private space (my proposal in this thread is
    touching this issue).

2. what if Object.create(objectWithPrivates, descriptor) ? would
descriptor methods be able to invoke objectWithPrivates.method()
with private(this) access in the function body? If yes, would that
private(this) refer to the objectWithPrivates? This would violate
the objectWithPrivates private concept, isn't it?

Object.create accept the __proto__ and a descriptor, I am not sure a
 descriptor will/should ever have a private(this) configured unless
there is not a class for the descriptor but the list of
configurations won't make much sense, i.e.

{value: function () { this instanceof OuterClass /* not possible, it's
just an object */ }}

It is an error to use private keyword outside the class block. So, no extension with private(this) using methods at all outside it. If aforementioned Object.create would appear inside class block, then according to actual state of the proposal, as I understand it, it is an error to use private keyword, too. It can only be used in methods (and constructor). But with I am less sure. My proposal is to make use of private keyword much more liberated, in that case if your Object.create would appear inside (any) class block, it would work and added (that class's whose the class block is) private access, outside class block it would not.

Herby
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to