On Jul 16, 2013, at 4:41 PM, Mark S. Miller wrote:

> 
> 
> I like the general idea. But when actually called simply as a function, this 
> would be unpleasant. Understanding that any ES5 behavior will be a compromise 
> to prepare the ground for ES6, I suggest this variant:
> 
> function MapConstructor() {
>   if (%_IsConstructCall()) {
>     %MapInitialize(this);
>   } else if (this === void 0) {
this test isn't sufficient is you really want to support constructors as 
callable factories.  Consider an namespace object (or a module) such as:

let ES6 = {Map, WeakMap, Set};
ES6.Map();

>     return new $Map();
>   } else {
>     throw ....;
>   }
> }
> 
> I already have a lot of code that simply calls WeakMap() without saying 
> "new". I suspect that others will too by the time they see v8's new built-in 
> WeakMaps.
We need to discourage leaving out the new, rather than trying to preserve the 
small amount (in terms of web scale) of existing code that uses Map/Set/WeakMap 
as callable factories. 

Allen

_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to