Hi folks,

I have updated PEP 642 significantly based on the feedback received
over the past week.

Since the Discourse thread hadn't received any comments on it, I
amended the existing thread in place rather than making a new one:
https://discuss.python.org/t/pep-642-constraint-pattern-syntax-for-structural-pattern-matching/5614

The full text of the PEP is quoted in the Discourse thread.

The rendered version of the updated PEP can be found in the usual
place: https://www.python.org/dev/peps/pep-0642/

Relative to the initially published version, the major changes are
based primarily on the counterproposal that Steven D'Aprano posted:

* Explicit equality constraints become "== EXPR" (replacing v1's "?EXPR")
* Explicit identity constraints become "is EXPR" (replacing v1's "?is EXPR")
* Inferred constraints are introduced to deal with the resulting
verbosity problems. These mostly follow the same syntax as PEP 634
proposes for value patterns and literal patterns, but are defined in
terms of the explicit constraints, rather than being the only way to
request the desired semantics.

While I considered ceding the point on using `_` as the wildcard
marker (and had updated the PEP to say that), I couldn't bring myself
to actually do it, especially after reading Thomas Wouters review of
the current state of the pattern matching proposals. So instead this
version proposes the use of `__` in that role, with an explanation of
how that opens a path towards restoring language self-consistency in a
future PEP by making `__` special everywhere, rather than only having
it be special in match patterns.

There are a few other changes that get down into the weeds of actually
implementing these features in the compiler (like introducing a
SkippedBinding node into the AST so most of the compiler doesn't need
to care how the wildcard is spelled in the surface syntax), but I
doubt those are going to matter to most folks in deciding which of the
proposals on offer they prefer (or if they'd prefer continue without
any pattern matching syntax at all).

Cheers,
Nick.

-- 
Nick Coghlan   |   ncogh...@gmail.com   |   Brisbane, Australia
_______________________________________________
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/IKAMHN3FVNHZEAEIMDRWFIAD4HXFQ24X/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to