Skip to content

Extend Patterns #2150

Closed
Closed
@Nokel81

Description

@Nokel81

This is the initial issue to reopen a few of the items from #99, not all but the ones that would be the most useful.

  1. The idea of the empty pattern, ! something that will never match anything.
  2. Extend the use of the & operator to be used for pattern set intersections: 1..5 & 3..8 is the range 3..5. If the patterns do not have any intersection then you get the ! pattern.
  3. Specify in the pattern specification that pat | pat -> pat no matter the location. This basically means that the | operator is used with patterns as a pattern set union operator. The requirement is that the patterns must extend over the same type just like in match statements currently.
  4. Add pattern guards (pattern if condition) to patterns properly. Once again, this would make the pattern syntax consistent with that of match arms. It could also be useful within let bindings: let ((a, _) if a > 5) | (_, a) = (e, f); would define a as the value of e if e > 5, and otherwise bind a to the value of f.

Metadata

Metadata

Assignees

No one assigned

    Labels

    T-langRelevant to the language team, which will review and decide on the RFC.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions