El dom, 9 ene 2022 a las 10:50, Chris Angelico (<rosuav@gmail.com>) escribió:
On Mon, Jan 10, 2022 at 3:49 AM Christopher Barker <pythonchb@gmail.com> wrote:
> > If "x->y" is syntactically valid anywhere in Python code, it's not a
> problem that there are no core data types for which it's meaningful.)
> Here's where I'm not so sure -- this looks a lot like a binary operator, but it behaves quite differently. IIUC it would always create a Callable, regardless of what the types were of the two other types. And it would not invoke a dinder on either, yes.
> Nor would it be like assignment.
> This is even worse than the use of [] in type hinting which is also using the same sytax for a very different meaning -- at least that one is stil calling __getitem__ :-)

From my understanding, "x->y" would create a Callable if given two
*types*, but its meaning if given two other objects is still
undefined. So there's still room for it to be an operator, just like
[] is, and for it to be given semantic meaning for the 'type' type and
all of its subclasses. Or alternatively, there's room for it to be
given meaning in a completely different way, but still universally
(there's a proposal for it to be a form of inline function, although
I'm not 100% sure of the details there).

With the current iteration of PEP 677, `(x) -> y` would return a special object (defined in the `types` module) that simply holds whatever `x` and `y` evaluate to. You could put whatever expression you want at runtime and it would work, though a static checker may be unhappy with you.

Python-Dev mailing list -- python-dev@python.org
To unsubscribe send an email to python-dev-leave@python.org
Message archived at https://mail.python.org/archives/list/python-dev@python.org/message/R6OIHWU5226BANUXMJLZID3KNUDBM4BL/
Code of Conduct: http://python.org/psf/codeofconduct/