System.Numerics Vector and Matrix types implementing operator interfaces #110463
Unanswered
StellarWolfEntertainment
asked this question in
Ideas
Replies: 2 comments 13 replies
-
If this limitation impacts your code, you may want to consider implementing it at least partially in F# which can constrain generic arguments on specific operators without having to go through an interface constraint: // Inferred signature of 'add':
// val inline add:
// a: 'a (requires static member ( + ) ) ->
// b: 'b (requires static member ( + ) )
// -> 'c
let inline add a b = a + b
let lhs = Vector4(1f, 2f, 3f, 4f)
let rhs = Vector4(5f, 6f, 7f, 8f)
let test = add lhs rhs
printfn $"{test}" |
Beta Was this translation helpful? Give feedback.
4 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I have a suggestion regarding the implementation of interfaces in the
System.Numerics
namespace. Specifically, types likeVector2
,Vector3
,Vector4
, and theMatrix
types implement the operator overloads (e.g., operator * for multiplication), but they do not explicitly implement the correspondingIMultiplyOperators<TSelf, TOther, TReturn>
interface, which would be a natural fit for these types.As far as I understand, there is no downside to implementing an interface when the function it declares is already implemented. Therefore, I would like to request that these vector and matrix types explicitly implement these operator interfaces where appropriate. This would provide clearer contracts and better interoperability with generic code that relies on these interfaces.
Please let me know if I'm missing something or if there's a specific reason these interfaces aren't implemented.
Beta Was this translation helpful? Give feedback.
All reactions