Skip to content
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

Add support for pattern additions #1026

Draft
wants to merge 3 commits into
base: draft-v9
Choose a base branch
from

Conversation

RexJaeschke
Copy link
Contributor

This PR might be incomplete; read below.

Regarding the MS proposal:

  1. Type patterns: Grammar rule primary_pattern is defined as something different from pattern, but as best as I can tell, they are exactly the same thing, so I replaced all occurrences of primary_pattern with pattern. Is that OK? (Also, the use of primary suggests here are secondary/other forms, but I don't see what they are.)
  2. Relational patterns: the proposed grammar shows relational_expression as the operand of each relational pattern, but the accompanying narrative goes on to constrain such relational expressions to constants only. So what not use *constant_expression" instead? And that's what I did. Am I missing something?
  3. Relational patterns: The proposal did not include support for enums, but as they are supported, I included them in the spec.
  4. Logical patterns: The proposal calls these pattern combinators; however, that term is not used elsewhere on MS's tutorial pages, so I used the more obvious (and elsewhere used) logical patterns instead.
  5. Logical patterns: The fact that the rule logical_pattern always expands to disjunctive_pattern may seem unnecessary, but it allows the placement of logical_pattern in the rule pattern rather than pushing the (odd-looking) disjunctive_pattern up there instead. (We use this approach elsewhere in the grammar.)
  6. The (substantial) second half of the proposal, "Open Issues with Proposed Changes," raises questions/issues. However, unlike all (or at least most) other MS proposals I've worked with, there is no follow-on discussion to say how these topics were actually addressed in the final implementation. Certainly, if any of the suggested approaches were taken, more words will need to be added to this PR to reflect that. I'll need help from someone at MS to resolve this.

This PR was created based on the assumption that the edits proposed by PR #873 for V8-related pattern-matching features will be adopted, and no other non-trivial edits will be made to that part of V8. When that PR is finally merged, this PR might need adjustment to reflect any changes in the V8 proposal review/adoption.

@RexJaeschke RexJaeschke added the type: feature This issue describes a new feature label Dec 7, 2023
@RexJaeschke RexJaeschke added this to the C# 9.0 milestone Dec 7, 2023
@RexJaeschke RexJaeschke marked this pull request as draft December 7, 2023 13:08
@gafter gafter self-assigned this Jan 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: feature This issue describes a new feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants