csharplang icon indicating copy to clipboard operation
csharplang copied to clipboard

Create spec for const expressions for is patterns

Open Rekkonnect opened this issue 2 years ago • 2 comments

Spec for #6926

CC @333fred

Rekkonnect avatar Oct 09 '23 23:10 Rekkonnect

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.

Rekkonnect avatar Dec 20 '23 14:12 Rekkonnect

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.

333fred avatar Jan 05 '24 19:01 333fred