typeof extensibility, building on my Value Objects slides from Thursday's TC39 meeting

Claude Pache claude.pache at gmail.com
Sat Aug 3 18:57:08 PDT 2013

Le 4 août 2013 à 01:34, Brendan Eich <brendan at mozilla.com> a écrit :

> Claude Pache wrote:
>> Fixing `typeof` of old (null) and new value types would be a solution, but I'm rather definitely considering something like the defunct `Object.isObject()`. (As a side-note, I suggest `typeof uint64(0) === "number"` rather than `=== "object"` by default.)
> That will make for bugs where number (double) loses precision, and other bugs where int64 carries too many bits of significand. It also violates the two-way
> (typeof x == typeof y && x == y) <=> (x === y)
> which we want for 0 == 0L, 1 == 1L, etc. (and consider other value types; this goes back to our work with Sam Ruby for IBM on decimal in 2008-9).

So, if I understand well, this mandates that int64 and float32 (for example) should have different typeof values, ergo both "object" (as in [1]) and "number" (as I proposed) are equally bad answers, and the most reasonable default value of typeof for int64 would be "int64"?

[1] http://wiki.ecmascript.org/doku.php?id=strawman:value_objects


More information about the es-discuss mailing list