typeof symbol (Was: Sept 19 TC39 Meeting Notes)

Brendan Eich brendan at mozilla.com
Mon Oct 1 16:45:36 PDT 2012


Axel Rauschmayer wrote:
>>> My main point was: any kind of simplification of the current 
>>> situation helps (even typeof o === "null" which, OTOH, might not be 
>>> worth the risk).
>>
>> We can't change typeof null === "null". V8 tried and it broke the 
>> web, and 1JS means we do not want typeof changing rules under module 
>> {...} -- that's a gratuitous refactoring hazard.
>>
>> typeof (function(){}) == "function" && typeof null == "object" && 
>> typeof {} == "object" -- just grieve and accept! I have :-P. Doesn't 
>> mean typeof is not useful and indeed widely used, and important for 
>> the ==/=== two-way implication. Other type tests would work for that 
>> implication, but typeof is the one in the language.
>
> I agree, sorry for not having been clearer – that’s what I meant by 
> “ might not be worth the risk”. But it seems to have come up again as 
> a possibility in this thread.

Not that I saw. Changing typeof result for existing inputs is off the 
table with 1JS.

>>> Regarding cross-frame: Many explanations on the web of determining 
>>> whether a value is an array sound like this is an impossible task 
>>> (ignoring Array.isArray()) and that’s a shame. Alas, I’m not sure 
>>> how one could do better here, it’s really a tricky problem. 
>>> postMessage seems like a partial solution.
>>
>> Or Object.prototype.toString.call(x).slice(8, -1) === "Array"? Not 
>> iron-clad but prior to Array.isArray, nothing is.
>
> Yes, but yet another special case: “use typeof (along with === and 
> !==), except where you have to use instanceof, except where you have 
> to access [[Class]] in a non-obvious manner”.
>
> I’m not complaining, merely suggesting that there must be a better 
> way. But I’ll offer something concrete by writing up a few thoughts.
>

Definitely can have better library solutions, including something in the 
standard library when "baked".

Let a thousand flowers bloom? (That was not auspicious for most flower 
growers, but nm.) The problem then becomes picking the prettiest flower, 
especially if the various users do not all agree.

/be


More information about the es-discuss mailing list