On Mar 20, 2012, at 3:02 AM, Andreas Rossberg wrote:
>
> How about reusing 'new'?
>
> let obj = do {
> let a;
> new {
> get a() {return a},
> set a()v) {a=v}
> }
> }
>
> That is, in 11.2.2, semantics of "new NewExpression", simply replace step 4
> with
>
> 4. If constructor does not implement the [[Construct]] internal method,
> return constructor.
>
> (Instead of throwing a TypeError. Probably want to rename 'constructor'
> there.)
>
> AFAICS, a plain object literal never has [[Construct]], so this should always
> work. Strictly speaking that is a breaking change, but it seems relatively
> unlikely that there is much code relying on the current error behaviour. But
> maybe I'm being naive. :)
This would preclude the new <object> proposal which allows any object to be
used as the operand for new. The semantics of new <object>(...args) would be
approximate:
{let temp = Object.create(<objet>);
let ctor = <object>.constructor;
if (typeof ctor == "function") ctor.call(temp, ...args);
temp
}
Allen
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss