csharplang
csharplang copied to clipboard
Create spec for const expressions for is patterns
Spec for #6926
CC @333fred
I believe we should also support tuple pattern matching expressions of the form (x, y) is (a, b), when x and y are also constants. This tuple syntax does not create a tuple value, but instead deconstructs the expression into two comparisons of the two values, equivalent to x is a && y is b. This can be evaluated in compile time, and thus is eligible for being supported from this change.
I did not add the above to the spec before discussing the idea, since it deviates from the classical concept of a constant expression by being primarily driven by syntactical simplification.
I believe we should also support tuple pattern matching expressions of the form (x, y) is (a, b), when x and y are also constants.
I don't think I'm willing to champion this. These are not constants today, and will need a good deal of language and compiler changes to implement. Let's keep the proposal to just the things that have been championed.