Structural Pattern Matching
Closed this issue · 1 comments
boisgera commented
Study https://www.python.org/dev/peps/pep-0622/ and see what would be required to make pattern matching possible.
Given the brief review I have made, I think that's merely the definition of attributes _arg1
, _arg2
, etc. associated to _args
and the definition of __match_args__
as ["_arg1", "_arg2", ...]
.
The idea would be to support feature extraction such as
match:
case Pandoc(Meta({"author", MetaInlines(author)}), _):
...
to get the author
metadata (as a list of inlines here).
boisgera commented
Actually _arg1
and so on would probably need to be read-only properties if _args
stays the source of truth.