On Fri, Oct 8, 2021 at 1:45 PM S Pradeep Kumar <gohan...@gmail.com> wrote:
> The Callable type is also usable as an expression, like in type aliases 
> `IntOperator = (int, int) -> int` and `cast((int) -> int, f)` calls.
>
> **Question 1**: Are there concerns we should keep in mind about such a syntax 
> proposal?
>

Either I'm reading this wrongly, or this is oddly inconsistent with
tuples. With a tuple, it's the comma that defines it; with function
parameters here, it looks like the parentheses are mandatory, and they
are what define it?

Which of these will be valid?

x = int -> int
y = int, int -> int # tuple containing (int, Callable) or function
taking two args?
z = (int,) -> int

Given the examples you've shown, my intuition is that it should match
def statement syntax - namely, the args are always surrounded by
parentheses, a trailing comma is legal but meaningless, and it has
nothing to do with tuple display. It would be very convenient for
one-arg functions to be able to be defined the way x is, and I suspect
people will try it, but it introduces annoying ambiguities.

There are parallel proposals to support a lambda syntax like "x =>
x.spam" as equivalent to "lambda x: x.spam", so I'm curious what the
rules would be for the two types of arrows, and whether they'd be
consistent with each other.

ChrisA
_______________________________________________
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/KIQQEIOC2D4INNAAIYWC6HH7GXPZWLXH/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to