syntax
syntax copied to clipboard
remove the physical equality operator `===`
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
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 ==
🤷♂️
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 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.
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).
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?
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?
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.