Re: Should Exceptions be Errors in the ECMAScript bindings?

Allen Wirfs-Brock:
> Actually, I now remember that what I originally had planned for ES6's {}.toStirng is that it would fall back to looking for well known, string valued private named property to supply the class name. Assume, that we can refer to that private property name as Reflect.names.toStringName.  If you (or WebIDL) want DOMException objects to {}.toString as "[object DOMException]" you would define:
>     Object.defineProperty(DOMException.prototype,Reflect.names.toStringName, {value: "DOMException"});
>
> (we haven't decided yet how these well known private name will actually be exposed so Reflect.names.toStringName is just a place holder).

As a way to have Web IDL platform objects return the right values when 
passed to {}.toString, that sounds fine to me.  For the moment, though, 
the Web IDL spec is targetting ES5.1.  Maybe we should have the v2 
document (now that I've branched it off) target ES6?

(As a reminder: what the spec currently says is not that [[Class]] has 
some custom values, but that after an ECMAScript environment is created, 
Object.prototype.toString is replaced with a version that does return 
the right values.  This AFAICT does not violate the ES spec, but it is a 
bit of a hack!)

Received on Saturday, 23 June 2012 02:14:03 UTC