Hello,

In the context of pattern matching, not accepting a match
subject that does not match any of the case clauses is
probably going to be frequent if not the most frequent.
Thus, when PEP 634, 635, 636 are -- hopefully -- accepted,
and experience with the feature is gained, this idea might
be worth reconsidering, allowing the rewrite of something like

https://github.com/gvanrossum/patma/blob/master/examples/over.py#L57-L68

```
match args:
    case [Point2d(x, y)]:
        return Point3d(x, y, 0)
    case [p := Point3d()]:
        return p
    case [x := int(), y := int()]:
        return Point3d(x, y, 0)
    case [x := int(), y := int(), z := int()]:
        return Point3d(x, y, z)
    case _:
        raise TypeError("Huh?")
```

into

```
match args:
    case [Point2d(x, y)]:
        ...
    case ...:
        ...
    case ...:
        ...
    case ...:
        ...
    case _:
        impossible
```

where `impossible` raises AssertionError.


Best regards,
Jean Abou-Samra
_______________________________________________
Python-Dev mailing list -- python-dev@python.org
To unsubscribe send an email to python-dev-le...@python.org
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at 
https://mail.python.org/archives/list/python-dev@python.org/message/3D6TDUJ4V3Q6DF3UCSBUF7ETGYAG46AJ/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to