Avoid boxing when comparing value types
When emitting code for comparison operators, the F# compiler already special-cases numeric types. I suggest that, when other value types have the appropriate operator, code is emitted to use it. I.e., the compiler should produce the equivalent of:
let inline (<=) (x: ^a when ^a: struct) (y: ^a) =
(^a: (static member (<=): ^a * ^a -> bool) (x, y))


This is effectively a duplicate of https://fslang.uservoice.com/forums/245727-f-language/suggestions/6098490-add-a-module-of-efficient-non-structural-equality
Don Syme, F# Language Evolution
1 comment
-
Abel commented
Just a note: while this has status "declined", it was a duplicate and the duplicate has been completed/resolved in F# 4.0.