On __proto__ as a magical data property
bruant.d at gmail.com
Thu Jul 19 02:55:57 PDT 2012
Le 19/07/2012 11:18, Tom Van Cutsem a écrit :
> 2012/7/19 David Bruant <bruant.d at gmail.com <mailto:bruant.d at gmail.com>>
> I agree with that vision and it is making me realize that we only
> need a setPrototypeOf trap if the setter is extractable. If
> __proto__ is a data property, the existing traps are enough.
> This probably weighs in favor of __proto__ as a data property.
> Well, it's true we don't need setPrototypeOf if we don't have a
> __proto__ setter, but I don't think that counts against
> __proto__-as-accessor. Proxy authors would still need to special-case
> on the string "__proto__" in the "set" trap, for instance, if they
> want to mimic the expected behavior.
I disagree. Forwarding to the target does what is expected, that is to
say changing the internal [[Prototype]] of the target (if it inherits
the property and __proto__ was not deleted). Actually, I'm not sure
about what the Reflect API is saying exactly about that.
There will be a need to special-case if the proxy author does *not* want
to mimic the proto setting behavior.
That's my reading of the current drafts. I'm unsure it's necessarily the
best situation though.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the es-discuss