Consistent decimal semantics
brendan at mozilla.org
Mon Aug 25 17:28:36 PDT 2008
On Aug 25, 2008, at 5:25 PM, Waldemar Horwat wrote:
> Brendan Eich wrote:
>>> - Should decimal values behave as objects (pure library
>>> implementation) or as primitives?
>>> If they behave as objects, then we'd get into situations such as
>>> 3m !=
>>> 3m in some cases and 3m == 3m in other cases. Also, -0m != 0m would
>>> be necessary. This is clearly unworkable.
>> What should be the result of (typeof 3m)?
> "decimal". It should not be "object" because it doesn't behave
> like other objects!
Ok, good (not "number"), but still a scary thing to contemplate if
your code switches on typeof and believes it handles all cases based
> Not doing option 2a or 2b would make it hard to write generic
> methods, it would mean that you could use decimals to index arrays
> but not pass them to Array.prototype methods (unless we made those
> special as well), etc.
Good point. Alternative 1 is really only for decimal-specific code.
Generic arithmetic wins if we can agree on 2a or 2b.
> I'm off to Burning Man! I'll continue this discussion next week.
More information about the Es-discuss