rescript-lang.org icon indicating copy to clipboard operation
rescript-lang.org copied to clipboard

Deep equal is not the `==` operator in JavaScript

Open uinz opened this issue 4 years ago • 2 comments

image

The == in ReScript is not equivalent to the == in JavaScript after compilation

In other words, Caml_obj.caml_equal is not equal to == in js

uinz avatar Nov 24 '21 04:11 uinz

Running into this today with my team. Its possible to do shallow and deep equality between polymorphic variants, for example, where the js representation is variable, and referential control is not clear, desired, (or possible), causing #Y(3) === #Y(3) to be false.

Whats worse is that Js developers have, in the recent past anyways, been taught to use === everywhere. So if they don't have any particular intent they will very often use === .

I have made some noise before but it strikes me that strict equality should be removed as an operator and moved to a Js specific location that clearly explains whats going on and prevents its use broadly in the language?

AlexMoutonNoble avatar Feb 25 '22 18:02 AlexMoutonNoble

see also #503

weakish avatar Sep 18 '22 05:09 weakish