Proposal: Enable use Span in generic delegates #1847
Replies: 9 comments
-
Why is it not sufficient to be able to define your own delegate types that accept/return |
Beta Was this translation helpful? Give feedback.
-
@HaloFour Any |
Beta Was this translation helpful? Give feedback.
-
Yes, The CLR forbids |
Beta Was this translation helpful? Give feedback.
-
|
Beta Was this translation helpful? Give feedback.
-
@AlexRadch No, you can't. Func<int> getInt = () => 1;
Func<object> getObj = getInt; does not compile. Covariance is available either through interface or type inheritance, if I am not mistaken. |
Beta Was this translation helpful? Give feedback.
-
@AlexRadch So what is the argument for enabling it? As far as I can tell, you haven't given any reason as for why this work should be done. |
Beta Was this translation helpful? Give feedback.
-
@svick What argument for disabling it? |
Beta Was this translation helpful? Give feedback.
-
For example why I should define separated delegate, where I can use public delegate int IndexOfFunc<T>(Span<T> span, T value);
public class MemoryExtensionsTests_IndexOfEqual<T>
{
public MemoryExtensionsTests_IndexOfEqual(IndexOfFunc<T> indexOf)
} Just use public class MemoryExtensionsTests_IndexOfEqual<T>
{
public MemoryExtensionsTests_IndexOfEqual(Func<Span<T>, T, int> indexOf)
} |
Beta Was this translation helpful? Give feedback.
-
@AlexRadch That's not how this works. The current state is that it's disabled. You want to enable it, in other words, you're proposing a new language feature. And since features are a lot of work, they require justification. If you can'y provide that, I think the chance that will be accepted to the language is incredibly low. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Enable use Span in generic delegates.
For example as input parameter
Func<Span<T>, T, int>
and as output parameterFunc<T, T, Span<T>>
.Beta Was this translation helpful? Give feedback.
All reactions