You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Func<T> is a function that returns a T is fairly simple to understand, but is has the caveat that the T can not be Void. If T could be Void then Action<> would the equivalent to a Func<Void>
This would allow us to conceptually consider the proposed match expression (#5016) as a Func<...,T>. Permitting it to also used a statement.
Func<T> is just a standard delegate, like countless others (including the other 16 Func<T, ...> delegates that ship with the framework).
Are you asking to make void/Void a possible generic type argument? Short of having a placeholder type like System.Void which would serve as a unit type I don't see how that would even approach being possible. There is only one IL body for any given generic method and it must be valid regardless of the generic type arguments, but that's certainly not possible if one of those arguments if void as that interferes with how the method could interact with the evaluation stack.
Even if you were to treat Func<T> and Action as special cases among the massive ecosystem of delegates they could not be compatible as they have different requirements of the caller. Invoking the former pushes a value onto the evaluation stack that the caller is required to at least pop in order to get equivalent semantics.
Func<T>
is a function that returns aT
is fairly simple to understand, but is has the caveat that theT
can not beVoid
. IfT
could beVoid
thenAction<>
would the equivalent to aFunc<Void>
This would allow us to conceptually consider the proposed match expression (#5016) as a
Func<...,T>
. Permitting it to also used a statement.One could write
return void;
, or it could be implicitly inferred.The text was updated successfully, but these errors were encountered: