On Thu, Aug 21, 2014 at 3:22 AM, Salvador de la Puente González <[email protected]> wrote: > The only problem I see here is you can not emulate completely `new` with ES. > Why Promise add some internal slots when called with new and it does not > make the same when writing `var p = Object.create(Promise.prototype); > Promise.call(p, fn);`?
Not true. See, for example: https://github.com/paulmillr/es6-shim/issues/170#issuecomment-34528376 https://github.com/paulmillr/es6-shim/blob/master/test/promise/subclass.js#L5 https://github.com/cscott/prfun/blob/master/lib/index.js#L520 It's super-annoying, but you can actually write ES5 code that will properly inherit the new internal slots in ES6. I'm a big fan of `Function.prototype.new`, though. And I think `Promise.new.bind(Promise)` is not all that terrible, if you want to pass around a constructor as a function. (And there's another es-discuss thread about trying to unify `new` as an "ordinary" function call in proxies as well.) --scott _______________________________________________ es-discuss mailing list [email protected] https://mail.mozilla.org/listinfo/es-discuss

