On Sat, Jul 11, 2020 at 5:28 PM Greg Ewing <greg.ew...@canterbury.ac.nz>
wrote:

> Just had another thought about marking assignment targets.
>
> The PEP currently forbids repeating bound names in a pattern
> to avoid raising expectations that
>
>      case Point(x, x):
>
> would match only if the two arguments were equal.
>
> But if assignment targets were marked, we could write this as
>
>      case Point(?x, x):
>
> and it would work as expected.
>

Yes. And if instead we marked name loads, e.g. with `^name`, we could write
it as
```
    case Point(x, ^x):
```
In fact, Elixir's "pin" operator is `^` and works this way.

I don't find it very intuitive that in order to write "it should be the
same x twice" you have to spell it differently -- it's more a clever trick
(that surely would become a hacker's idiom if we allowed it).

-- 
--Guido van Rossum (python.org/~guido)
*Pronouns: he/him **(why is my pronoun here?)*
<http://feministing.com/2015/02/03/how-using-they-as-a-singular-pronoun-can-change-the-world/>
_______________________________________________
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/7QQDOTLSQI53LYHQLFP3ZCBODBKBATBR/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to