On 7/16/2013 4:56 PM, Brendan Eich wrote:
Mark's suggestion seems better because it throws on random wrong this but supports strict calls by unqualified name.

I don't think that it'd be nice if `Map()` could throw or not throw depending on strictness of the caller. Working around that requires something like:

    function Map(...args){
      if (this === undefined || this === %CallerGlobal()) {
        return new Map(...args);
      } else if (!%HasMapData(this)) {
        throw new TypeError("Not a Map");
      } else if (%HasInitializedMapData(this)) {
        throw new TypeError("Map is already initialized");
      }
      %MapInitialize(this);
    }

(V8's implementation is also incorrect in that it doesn't throw when you do `Map.call(new Map)`) (so is SM's)
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to