On 17 February 2017 at 18:13, Joshua Morton <joshua.morto...@gmail.com>
wrote:

> @ Joseph
>
> Function annotations can be arbitrary python expressions, it is completely
> legal to have something like
>
>     >>> def foo(bar: lambda x: x + 1):
>     ...     pass
>
> Why you would want that I can't say, but it is legal. In the same way,
> `def foo(bar: delayed 1 + 1)` should probably be legal syntax, even if the
> use is inexplicable. (also note that the `:` works with lambda because
> lambda cannot be used as an identifier). In any case, as David said,
> bikeshedding.
>

Sorry for lack of clarity: I see that it is legal for lambda, I suggest
that the value of extending this to delayed: to be not worth the cost of
potentially being backwards-impompatible. I say that because if delayed:
were to work in function definitions, whenever the definition was
evaluated, the delayed would be as well. (The same is true for if, for, and
while.) This would be different if the delayed was inside a function call
inside a function definition. (but in that case there would be no
collision).
_______________________________________________
Python-ideas mailing list
Python-ideas@python.org
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to