[Python-ideas] Delayed Execution via Keyword

Joseph Hackman josephhackman at gmail.com
Fri Feb 17 18:20:35 EST 2017


On 17 February 2017 at 18:13, Joshua Morton <joshua.morton13 at 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).
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20170217/34b807a1/attachment.html>


More information about the Python-ideas mailing list