-
Notifications
You must be signed in to change notification settings - Fork 4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Question: could/will patttern matching expressions support void results? #9717
Comments
Yes I'm aware of @grafter's opinion on the matter. I feel his position is ill-thought out though given that |
@DavidArno So you've already made your argument and at least one member of the LDM team has weighed in. I don't see what repeating that argument will buy you considering that you haven't added anything new. The team clearly has a different idea as to the direction of the implementation of pattern matching in C# than you do. You're welcome to your opinion that this is a train wreck. I'm not sure that constantly voicing this will do much to improve your argument. |
The only expression that might return Your example could be written like this: void OptionValue<T>(Option<T> option) =>
option is Some(var value) ? Console.WriteLIne($"Value is {value}")
: Console.WriteLIne("No value"); Which won't compile either. Same is true for |
|
It doesn't wrap anything, it is the production rule for a method invocation.
It was there since version 1.0.
Because it's not an invocation expression. I think you are misunderstanding C# grammar. |
Maybe there could be a standard https://msdn.microsoft.com/en-us/library/system.reactive.unit(v=vs.103).aspx
http://www.introtorx.com/content/v1.0.10621.0/04_CreatingObservableSequences.html
Inspired by F# I guess: https://msdn.microsoft.com/en-us/library/dd483472.aspx
|
It would of course lead to proliferation of libraries that would not provide |
I had assumed that |
The current specification for the pattern-matching expression uses specification terminology similar to the terminology describing the result type of |
Currently - as I understand it - it is proposed that
switch
be extended to support pattern matching and that a new keywordmatch
by added to support pattern matching expressions. Assuming aOption<T>
union, their respective syntaxes might be:However, Roslyn already supports, for example,
InvocationExpression
andSimpleAssignmentExpression
for void expression bodies, such asThe notion of statements being expressions and vice versa is already baked into the language. Thus it ought to be possible to to treat
match
similarly, such that it can be avoid
statement or expression:Will this be possible, and if so, is it planned for the pattern match expression supporting release of C#?
The text was updated successfully, but these errors were encountered: