-
Notifications
You must be signed in to change notification settings - Fork 783
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Reference equality optimisation commented out in implementation of (=) #15486
Comments
That said in practice there would be a host of types where performing pointer equality checks would be 100% safe, e.g. int list or string list or (int * string) list. These would loosely speaking be types with known equality semantics on the elements (no exceptions, termination, respects (X = X) == true etc.) The problem is that the more of these special cases you bake in, the more the programmer needs to know. To give one other example: what about |
The NaN thing wouldn't apply to when the ER flag is true in this function. Also about optimisation sensitivity - does Debug/Release config change object identity? How is that relevant here? |
The only one of these I'm really, really, really afraid of is "Infinite loops can be suppressed "by luck"." It's hard enough to explain let rec tail recursion, but if it doesn't even happen that would make my life much harder. Something that works when it shouldn't is far more harmful than something that doesn't work when it should, because it's "fail safe". Let rec was already a bit "fail dangerous" as it is. It would mean a lot to me if we can properly rule this out or prevent it before making this kind of optimization. |
This optimization is unsafe and won't be implemented in the foreseeable future. |
fsharp/src/FSharp.Core/prim-types.fs
Line 1432 in e25475c
Why is this the case? It seems to be a low hanging optimisation that went unused especially since this optimisation is used even inside the BCL implementation of
object.Equals
.https://github.com/dotnet/runtime/blob/0633ecfb79a3b2f1e4c098d1dd0166bc1ae41739/src/libraries/System.Private.CoreLib/src/System/Object.cs#L55
The text was updated successfully, but these errors were encountered: