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
This is a possible unification of the syntax for the positional pattern, property pattern, tuple pattern, var pattern, and type pattern.
The syntactic constraints on the syntax for recursive_pattern are as follows:
At least one of the parts before the identifier is required.
The pattern_type may not be a tuple type.
Furthermore, when a positional_subpattern is present, a identifier or property_subpattern may only be present if the positional_subpattern binds to a tuple type or a type with a self-typed deconstructor.
Point M()=> ...;if(M()is(var x, var y) p { Length is5}) Console.WriteLine(p);
Note that with this new proposed syntax we would not allow the use of tuple types for the type due to an ambiguity with the positional part of the pattern.
It makes the var unnecessary, regardless of the presence of the type itself. However you might want to consider a keyword or token before the identifier, specially in array patterns, etc because it's almost invisible.
caseT id:
case ( .. ) id:
case { .. } id:
case T( .. ) id:caseT{ .. } id:
case T( .. ){ .. } id:
I'd like to suggest to unify match and case expressions as well,
This discussion was converted from issue #473 on September 08, 2020 20:15.
Heading
Bold
Italic
Quote
Code
Link
Numbered list
Unordered list
Task list
Attach files
Mention
Reference
Menu
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
@gafter commented on Fri Apr 15 2016
This is a possible unification of the syntax for the positional pattern, property pattern, tuple pattern, var pattern, and type pattern.
The syntactic constraints on the syntax for recursive_pattern are as follows:
Furthermore, when a positional_subpattern is present, a identifier or property_subpattern may only be present if the positional_subpattern binds to a tuple type or a type with a self-typed deconstructor.
@gafter commented on Fri Apr 15 2016
@AlekseyTs @agocke FYI
@bbarry commented on Mon Apr 18 2016
Effectively a change something like this to patterns.md?
edit: added
identifier?
to positional_pattern; but yes I see how you are combining and this doesn't get you that.@gafter commented on Mon Apr 18 2016
@bbarry No, that wouldn't allow
Note that with this new proposed syntax we would not allow the use of tuple types for the type due to an ambiguity with the positional part of the pattern.
@alrz commented on Mon May 09 2016
I believe @bbarry meant the ability to name the whole pattern in positional patterns,
Also, I think it reads better if you put the identifier at the end in property patterns,
It makes the
var
unnecessary, regardless of the presence of the type itself. However you might want to consider a keyword or token before the identifier, specially in array patterns, etc because it's almost invisible.I'd like to suggest to unify
match
andcase
expressions as well,This probably makes it easier to disambiguate it with the
case
keywords withinmatch
expression.Beta Was this translation helpful? Give feedback.
All reactions