Mark S. Miller (2015-04-29T18:07:57.000Z)
Hi Scott, I think your approach is on the right track. How about the
following?

Anyone see a way to attack it?



const goodPromises = new WeakSet();
class DefensivePromise {
  constructor(x) {
    super(x);
    if (new.target === DefensivePromise) {
      Object.freeze(this);
      goodPromises.add(this);
    }
  }
  static resolve(x) {
    if (goodPromises.has(x)) {
      return x;  // should be equiv to super.resolve(x);
    }
    return new DefensivePromise(r => {r(x)});
  }
}


Note a few typos fixed and a few simplifications, all of which you should
double check. Thanks!


--
    Cheers,
    --MarkM
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20150429/70a275d4/attachment-0001.html>
d at domenic.me (2015-05-11T16:44:14.812Z)
I think your approach is on the right track. How about the
following?

Anyone see a way to attack it?

```js
const goodPromises = new WeakSet();
class DefensivePromise {
  constructor(x) {
    super(x);
    if (new.target === DefensivePromise) {
      Object.freeze(this);
      goodPromises.add(this);
    }
  }
  static resolve(x) {
    if (goodPromises.has(x)) {
      return x;  // should be equiv to super.resolve(x);
    }
    return new DefensivePromise(r => {r(x)});
  }
}
```

Note a few typos fixed and a few simplifications, all of which you should
double check.