jack-pappas / ExtCore

An extended core library for F#.
Apache License 2.0
178 stars 32 forks source link

ping pong in documentation of == and === #38

Open 7sharp9 opened 6 years ago

7sharp9 commented 6 years ago

== refers to obsolete use === === refers to obsolete use ==

https://github.com/jack-pappas/ExtCore/blob/master/ExtCore/Pervasive.fs#L105-L113

jack-pappas commented 5 years ago

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:

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.

wallymathieu commented 5 years ago

From what I can see it's already implemented in ocaml compatibility https://github.com/fsprojects/FSharp.Compatibility/blob/master/FSharp.Compatibility.OCaml/Pervasives.fs#L53-L59

/// 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