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

Brendan Eich brendan at mozilla.com
Sat Aug 3 16:34:27 PDT 2013


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).

> But here is a potential good use of customisable `typeof`: I expect 
> that sometimes you do not want to distinguish between int64, bignum, 
> etc. (set typeof to "number" for all cases), but sometimes you do want 
> to distinguish between them (set distinct typeof values). For this 
> case, the scope of the modification should definitely be lexical, not 
> dynamic.

We're not going to mix non-double numeric types -- types whose values do 
not project losslessly into IEEE-754 double -- as "number".

/be


More information about the es-discuss mailing list