Es-discuss - several decimal discussions

Brendan Eich brendan at
Mon Aug 25 13:19:04 PDT 2008

On Aug 25, 2008, at 4:29 AM, Sam Ruby wrote:

>> If Decimal is an object type, then typeof 1.0m == "object" is good
>> for a couple of reasons:
>> * Future-proof in case we do add a primitive decimal type, as ES4
>> proposed -- a peer of double that shares Number.prototype; typeof on
>> a decimal would return "number". See below for the possibly-bogus
>> flip side.
> What would be the upside to such an approach?  I can see the
> next-edition-of-ES-that-provides-decimal (my working assumption still
> is "3.1" whatever that may be called, others may be understandably
> skeptical) only providing a Decimal object, and with that addition the
> language with respect to decimal being considered a steady state that
> not need to be revisited in subsequent editions.

Yes, I was being a little too generous with the possibility of a  
primitive making a come-back. If we evolve by adding Decimal as an  
"object" typeof-type, that's it. Probably better this way in the long  
run, the operator extensions should inform our evolving thinking on  
generic arithmetic and multimethods.

>> * Analogous to RegExp, which has literal syntax but is an object
>> (RegExp is worse because of mutable state; Decimal presumably would
>> have immutable instances -- please confirm!).
> I'd prefer if Decimal instances in ES were considered immutable and
> automatically "interned".  By the latter, I simply mean that new
> Decimal("1.0") === new Decimal("1.0").

The spec should say this.

Decimal.prototype would be extensible and not sealed, however, just  
as other standard constructor prototype objects are. A bit of a  
challenge in the spec, and in implementations that make an  
unconstructed primordial instance be the class prototype, but not  
insuperable (hand-wave alert).


More information about the Es-discuss mailing list