syntax icon indicating copy to clipboard operation
syntax copied to clipboard

remove the physical equality operator `===`

Open bobzhang opened this issue 4 years ago • 6 comments

Unlike JavaScript's ===, for ocaml, most places where === is used, it is a wrong use case, it is useful in a small places where some internal optimizations is applied. In such small use cases, we can just call it like a normal function instead of using a special operator

bobzhang avatar Jul 30 '20 01:07 bobzhang

This is a tough one in my opinion. People in JavaScript have been taught to use === almost to the point of indoctrination (and it makes sense in JS of course). There is a lot of muscle memory involved, so this could hinder the "feel good" ambition of the new syntax for onboarding. There is no easy option here - we can hardly just make === equal to == 🤷‍♂️

jsiebern avatar Jul 30 '20 01:07 jsiebern

Note ocaml’s === is not the same as ===. Or we just redefine === into === but that would have some other implications

Jonathan [email protected]于2020年7月30日 周四上午9:26写道:

This is a tough one in my opinion. People in JavaScript have been taught to use === almost to the point of indoctrination (and it makes sense in JS of course). There is a lot of muscle memory involved, so this could hinder the "feel good" ambition of the new syntax for onboarding. There is no easy option here - we can hardly just make === equal to == 🤷‍♂️

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/BuckleScript/syntax/issues/83#issuecomment-666021412, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAFWMK54AUYSFP2EDVCMX33R6DD35ANCNFSM4PMPJK7A .

-- Regards -- Hongbo Zhang

bobzhang avatar Jul 30 '20 01:07 bobzhang

@bobzhang Yeah, I'm aware they're different and therefore are being misused most of the time. I just think it's a tough call to take the operator away for Javascripters though, for the above reasons. I'm not saying this shouldn't happen, not at all. I'm just trying to offer some perspective, because I for one would miss the operator immensely if I transitioned freshly to Reason/BS now.

jsiebern avatar Jul 30 '20 01:07 jsiebern

It's indeed a tough call. But to play devil's advocate: @jsiebern we have a parser that can warn now, so in the very least we can just show a syntax error and tell folks to use ==. Or even accept === and format to == (which is super dangerous but it's doable).

chenglou avatar Jul 31 '20 08:07 chenglou

Am I understanding this correctly that you would like to remove === (compiling to JS ===) from the Reason syntax and people should use == (compiling to Caml_obj.caml_equal) instead?

cknitt avatar Jul 31 '20 11:07 cknitt

Would be happy to see this over here too. Js devs definitely reach for ===, or its left in naturally during a porting process [in our codebase]. We dont have referential control over variants, so === will behave in surprising ways it seems. e.g. #Y(3) === #Y(3) // false but #X === #X //true` Definitely holding true the tradition of bizzarre Js equality =D If its not universally behaved I think it should not be a universal operator.

Js trend is to have both equalities behave the same via transpilation i think? Could be ok to make them equal before taking one away?

AlexMoutonNoble avatar Feb 25 '22 18:02 AlexMoutonNoble

The rescript-lang/syntax repo is obsolete and will be archived soon. If this issue is still relevant, please reopen in the compiler repo (https://github.com/rescript-lang/rescript-compiler) or comment here to ask for it to be moved. Thank you for your contributions.

stale[bot] avatar May 28 '23 19:05 stale[bot]