Domenic Denicola wrote:
From: Brendan Eich [[email protected]]

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.

People do depend on this, though. Some JS users take advantage of ==, in particular of

* null == undefined
* typeof x == typeof y

The latter makes use of knowledge that typeof's result is always of string type.

You may argue people should always use === everywhere, but it's a fact that == is supported *and* used.

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

False. When operand typeof-types match, == is short for === and people use this (second bullet above is the most common case I've seen, but not the only case).

  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.

As I wrote last time, *we* language designers/stewards of TC39 care for good reason.


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

Let's cut this thread mercifully short. Language designers tending ECMA-262 cannot turn such a blind eye, period, full stop.

/be
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to