dotnet / runtime

.NET is a cross-platform runtime for cloud, mobile, desktop, and IoT apps.
https://docs.microsoft.com/dotnet/core/
MIT License
15.05k stars 4.69k forks source link

Determine whether generic math interfaces need to express variance #74148

Open stephentoub opened 2 years ago

stephentoub commented 2 years ago

See discussion in https://github.com/dotnet/runtime/pull/74025#issuecomment-1217129862. The question is whether the new generic math interfaces being introduced in .NET 7 should express co/contravariance (in and out on the various generic type parameters), e.g. https://github.com/dotnet/runtime/commit/197d96f92887c0032c5d19dff47d377cf63672f4. It's not clear if there are meaningful scenarios for it or if adding them now could conflict with future language work, but it could also be a breaking change to add them later.

Seems likely we should just leave them as-is, but we should make an explicit decision.

ghost commented 2 years ago

Tagging subscribers to this area: @dotnet/area-system-numerics See info in area-owners.md if you want to be subscribed.

Issue Details
See discussion in https://github.com/dotnet/runtime/pull/74025#issuecomment-1217129862. The question is whether the new generic math interfaces being introduced in .NET 7 should express co/contravariance (in and out on the various generic type parameters), e.g. https://github.com/dotnet/runtime/commit/197d96f92887c0032c5d19dff47d377cf63672f4. It's not clear if there are meaningful scenarios for it or if adding them now could conflict with future language work, but it could also be a breaking change to add them later. Seems likely we should just leave them as-is, but we should make an explicit decision.
Author: stephentoub
Assignees: tannergooding
Labels: `area-System.Numerics`
Milestone: 7.0.0
hez2010 commented 2 years ago

I don't see any use case against co/contravariance on generic math. Generally we are using generic math against structs. And even if we support it, currently we have no way to call a static interface member on interface type directly without a type parameter.

jeffhandley commented 2 years ago

@tannergooding (and @dotnet/area-system-numerics), have you reached a conclusion on this? If we decide to add the expressions, we would need to do so before the RC2 snap.

dakersnar commented 2 years ago

@tannergooding and I discussed this on Friday and have decided we are not going to include this feature. He plans on sending a longer explanation here but for now we can remove the blocking-release tag.

jeffhandley commented 2 years ago

I want to keep this in the 7.0.0 milestone, but labeled as documentation. We need to have notes about variance in the docs and/or here so that folks who ask about this again can understand why we chose not to express it.

akoeplinger commented 10 months ago

@jeffhandley should this still be kept in the 7.0.0 milestone?

jeffhandley commented 10 months ago

Oops; nope. Thanks; updated.