B.3.1 The __proto__ pseudo property

Tom Van Cutsem tomvc.be at gmail.com
Mon May 20 08:17:12 PDT 2013


2013/5/9 Brendan Eich <brendan at mozilla.com>

> Andreas Rossberg wrote:
>
>    (And let's bury setPrototypeOf quickly.)
>>
>
> Bury how? IIUC this goes in main spec alongside ES5's
> Object.getPrototypeOf, requires a proxy trap, etc.


Here's one potential alternative: add Reflect.setPrototypeOf but not
Object.setPrototypeOf.

Rationale:
- Under Allen's proposal upstream of this thread, proxies will require a
setPrototypeOf trap, regardless of whether we expose Object.setPrototypeOf
(proxies will need to intercept protosetter.call)
- every trap in the Proxy API has a corresponding method with matching
signature in the reflection module to make it easy for proxies to forward
intercepted ops.
- it follows that we'll have Reflect.setPrototypeOf in the reflection module

The question then becomes whether we additionally want to expose an
Object.setPrototypeOf alias for this method.

Putting the setPrototypeOf method only in the reflection API but not on
Object could be a way of telling developers that setting the prototype of
an object is a reflective operation, to be used with some care, not a
general utility function to be used routinely.

Cheers,
Tom
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20130520/2489a12d/attachment.html>


More information about the es-discuss mailing list