
On Mon, 13 Jul 2020 at 09:30, Federico Salerno <salernof11@gmail.com> wrote:
On 13/07/2020 00:20, Guido van Rossum wrote:
The need for a wildcard pattern has already been explained -- we really want to disallow `Point(x, y, y)` but we really need to allow `Point(z, _, _)`. Generating code to assign the value to `_` seems odd given the clear intent to *ignore* the value.
Would it be impossible for the parser to interpret Point(x, y, y) as "the second and third arguments of Point must have the same value in order to match. Bind that value to y"? Since the value has to be the same, it doesn't matter whether y binds to the first or the second (or the nth) instance of it.
No, that would not be impossible but fraught with problems. This is discussed in the PEP: https://www.python.org/dev/peps/pep-0622/#algebraic-matching-of-repeated-nam...