Es-discuss - several decimal discussions

Maciej Stachowiak mjs at
Sat Aug 23 13:23:58 PDT 2008

On Aug 23, 2008, at 11:30 AM, Sam Ruby wrote:

> ihab.awad at wrote:
>> On Sat, Aug 23, 2008 at 10:04 AM, Sam Ruby <rubys at>  
>> wrote:
>>> Decimal implemented as a library would be sufficient for a 3.1
>>> release.  The problem is an interoperable definition for what infix
>>> operators is required for completeness.  Taking no other action, the
>>> default behavior for the result of a "+" operator given a Number  
>>> and a
>>> library provided Decimal would be to convert both to string
>>> representations and concatenate the results.
>> In other words, the same as the "+" operator given a Number and a
>> library provided Employee, Document, PopupWidget, ..., or any other
>> user defined type.
> Having Decimal.parse(2) + 3 produce "23" is not what I would call  
> "fail
> fast", as that is a term I would typically use for throwing an  
> exception
> or the like.

One possible way to achieve "fail fast" in a library only solution  
would be to specify that Decimal.prototype.valueOf always throws an  
exception. This would make an attempt to add or multiply using the  
operator throw, but would still allow decimal numbers to be printed,  
and would allow for explicit conversion methods.


More information about the Es-discuss mailing list