Tom Van Cutsem (2014-06-13T10:33:39.000Z)
domenic at domenicdenicola.com (2014-06-20T19:36:46.996Z)
Interesting. It'd be nice if we could further simplify the Proxy/Reflect API. Given the local nature of these changes, we might still include it in ES6 if we achieve quick consensus. As Allen mentioned, this came up a number of times in TC39 meetings and I believe the fear for exotic objects that require control over [[Construct]] was the biggest show-stopper. If more knowledgeable people like Boris can vouch for the fact that this isn't the case, that would remove the biggest roadblock. Scott is right: Reflect.construct essentially directly calls [[Construct]], so the Reflect API already provides the power to construct objects without the new operator. There are no security concerns that I can spot. Cc'ing Mark. One important detail: Jason proposes: new C(...args) => C[Symbol.new](...args) Allen proposes: new C(...args) => C.apply(C[Symbol.create](), args) I prefer Jason's transformation for the following reason: imagine a proxy that wants to implement e.g. a flyweight pattern (i.e. it wants to pool or cache objects, rather than constructing a fresh object for each call to |new|). This is trivial to do with Jason's transformation, because the proxy is in control of *both* object allocation and initialization. With Allen's transformation, we need to jump through some hoops if the cached object returned by Symbol.create depends on args (which is common for flyweights), as they only get passed in after Symbol.create returns. We can debate whether `C[Symbol.new]` should be called with args collected in an array or spliced. I have no preference.