Error objects: RangeError, TypeError, ValueError

Allen Wirfs-Brock allen at
Tue Nov 29 14:34:43 PST 2011

On Nov 30, 2011, at 9:06 AM, David Herman wrote:

> On Nov 22, 2011, at 10:14 AM, Brendan Eich wrote:
>> On Nov 22, 2011, at 9:37 AM, Allen Wirfs-Brock wrote:
>>> Range error actually has fairly limited usage in the current specification.  Enough so, that it arguably doesn't carry its weight as one of the very few available exceptions "classes".    I think we could reasonably drop the "numeric" from its prose description and use it for all (new) situations where a provided value is of the correct "type" but outside the set of acceptable values of that type. 
>> Pedants and wannabes like me will object to "Range" instead of "Value" (codomain vs. domain :-P). But agreed, we could use RangeError in more places; we could do worse.
> And then pedants like me will object to your interpretation of "range" in this context. :) The way "range" is being used is as an "interval", which is common in CS, and not the same as the mathematical tradition. (In fact, there are multiple conflicting uses of the word "range" in math.)

Except that ES doesn't even consistently follow that definition.  For example: If the argument len is a Number and ToUint32(len) is equal to len, then the length property of the newly constructed object is set to ToUint32(len). If the argument len is a Number and ToUint32(len) is not equal to len, a RangeError exception is thrown.

new Array(1.2)
RangeError on line 1: invalid array length

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the es-discuss mailing list