You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Thank you for bringing this up. You're right, it should be fixed.
Background context: I think I originally used === for the physical equality (aka reference equality) operator, but later introduced == because that's what OCaml's Pervasives module uses and I thought it might be more familiar for anyone switching between F# and OCaml.
However, I failed to consider whether == would be confusing for C# developers getting into F#. After speaking to a developer at work who ran into that exact issue (== vs. =), I realized the C# -> F# scenario is much more likely and having an auto-imported == operator means that:
Devs used to working in C# can use == and won't get a syntax error telling them they should be using = instead.
If comparing two reference-typed things (e.g. F# records or DUs), accidentally using == instead of = means the program will compile but will almost certainly not have the expected behavior.
I think the solution here is to make a breaking change in ExtCore 1.0 to remove the == operator and un-deprecate ===. It'll eliminate confusion for developers new to F# and it'll fix this circular-deprecation issue as well. If we need to preserve the == operator, I think it's probably best to move it over to the FSharp.Compatibility.OCaml project under fsprojects/FSharp.Compatibility.
/// e1 == e2 tests for physical equality of e1 and e2.
let inline ( == ) x y =
LanguagePrimitives.PhysicalEquality x y
/// Negation of (==).
let inline ( != ) x y =
not <| LanguagePrimitives.PhysicalEquality x y
==
refers to obsolete use===
===
refers to obsolete use==
https://github.com/jack-pappas/ExtCore/blob/master/ExtCore/Pervasive.fs#L105-L113
The text was updated successfully, but these errors were encountered: