Replies: 4 comments 6 replies
-
Support this. Would be quite handy. |
Beta Was this translation helpful? Give feedback.
-
This is a great proposal. I would also love it if constraints were automatically inherited based on inference. For example, this code is redundant:
I should be able to say:
And have Super's |
Beta Was this translation helpful? Give feedback.
-
@TonyValenti https://ericlippert.com/2013/07/15/why-are-generic-constraints-not-inherited/ |
Beta Was this translation helpful? Give feedback.
-
I wonder why the original design was done this way in .NET using the Does anyone know why .NET decided on the verbose and duplication-prone strategy for defining constraints in the first place? I assume there must've been a strong reason at the time. |
Beta Was this translation helpful? Give feedback.
-
Inline type constraints
Proposal: dotnet/roslyn#7671
With numerous type parameters, type constraints require duplicating every type parameter to the point that it's somehow confusing,
Inlining type parameters could significantly reduce noise around the type declaration,
This syntax would bring type parameter constraints closer to their declaration,
Inlined type constraints can be mixed with default type parameters (#278), e.g.
Multiple type constraints can be inlined using "intersection types", using whatever syntax that they're going to use,
However, it might be actually preferable to only allow "simple" type constraints in this manner.
Beta Was this translation helpful? Give feedback.
All reactions