Tom Van Cutsem (2013-09-13T10:35:15.000Z)
2013/9/13 David Bruant <bruant.d at gmail.com>
>
> If one wants Object.getPrototypeOf to return the same object twice, the
> membrane has to associate a new prototype with a given object. If there is
> a shadow target, the place of where to store this object is pretty obvious
> ([[Prototype]]).
> That said, the good property that remains is that if a prototype setting
> capability has been kept around is that prototype chains can be built
> lazily.
>

Returning the same object twice is taken care of by the use of WeakMaps,
separately.

I'm thinking of an implementation as follows:

// in a wet->dry membrane proxy's handler:
getPrototypeOf: function(dryShadow) {
  if (!Object.isExtensible(wetTarget)) {
    // no need to use the shadow
    return wet2dry(Object.getPrototypeOf(wetTarget)); // wet2dry consults a
WeakMap to avoid creating multiple wrappers
  }
  var dryProto = wet2dry(Object.getPrototypeOf(wetTarget));
  Object.setPrototypeOf(dryShadow, dryProto);
  return dryProto;
}

Cheers,
Tom
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20130913/a2c91982/attachment.html>
domenic at domenicdenicola.com (2013-09-25T01:46:27.489Z)
2013/9/13 David Bruant <bruant.d at gmail.com>
>
> If one wants Object.getPrototypeOf to return the same object twice, the
> membrane has to associate a new prototype with a given object. If there is
> a shadow target, the place of where to store this object is pretty obvious
> ([[Prototype]]).
> That said, the good property that remains is that if a prototype setting
> capability has been kept around is that prototype chains can be built
> lazily.
>

Returning the same object twice is taken care of by the use of WeakMaps,
separately.

I'm thinking of an implementation as follows:

```js
// in a wet->dry membrane proxy's handler:

getPrototypeOf: function(dryShadow) {
  if (!Object.isExtensible(wetTarget)) {
    // no need to use the shadow
    return wet2dry(Object.getPrototypeOf(wetTarget)); // wet2dry consults a WeakMap to avoid creating multiple wrappers
  }
  var dryProto = wet2dry(Object.getPrototypeOf(wetTarget));
  Object.setPrototypeOf(dryShadow, dryProto);
  return dryProto;
}
```