From: Brendan Eich [bren...@mozilla.com]

> Yes, and I've written about why invariants matter on occasion -- perhaps you 
> missed that :-P.

Heh, 2008 was before my time. But generally yes, I certainly understand the 
importance of invariants. I am just not sure this particular invariant is 
something people actually depend on.

This I guess is the heart of my question. When I said "nobody uses `==`," I 
should have said "nobody writes code using `==` that depends on that logical 
equivalence." The `typeof x == "object" && !x => x === null` invariant I can 
certainly see being used in the wild, mainly to avoid the special-caseness of 
`null` being an object-according-to-`typeof`, but I can't for the life of me 
think of how to use the `typeof`/`==`/`===` relation.

> It's not an equality, rather a two-way implication. It helps us reason about 
> all three of typeof, ==, and === as we evolve JS. It's not noise, and not 
> nothing.

My perspective is that reasoning about `==`, and even to some extent `typeof`, 
is not that important, since they are both "broken." And thus such a connection 
does feel somewhat like noise; there are plenty of invariants you can state by 
just stringing together logical consequences of the language, but determining 
which of those are important is the trick.

Anyway, I get it that good invariants are useful and that you at least find 
this particular invariant to be a good one, so we can leave it at that. I'd 
still love to see some plausible-in-the-wild code that could break if we lost 
this invariant, though.
_______________________________________________
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to