pep-0492: 'Why not reuse existing "for" and "with"...' section

This commit is contained in:
Yury Selivanov 2015-04-23 15:53:20 -04:00
parent 8935feb87c
commit 2feb4ad5c3
1 changed files with 12 additions and 2 deletions

View File

@ -754,13 +754,13 @@ Differences from this proposal:
6. Requiring parentheses grammatically also introduces a whole lot
of new problems.
Code like the following::
The following code::
await fut
await function_returning_future()
await asyncio.gather(coro1(arg1, arg2), coro2(arg1, arg2))
would look like::
would look like::
cocall fut() # or cocall costart(fut)
cocall (function_returning_future())()
@ -951,6 +951,16 @@ This approach has the following downsides:
simple and foolproof as possible.
Why not reuse existing "for" and "with" statements
--------------------------------------------------
The vision behind existing generator-based coroutines and this proposal
is to make it easy for users to see where the code might be suspended.
Making existing "for" and "with" statements to recognize asynchronous
iterators and context managers will inevitable create invisible
implicit suspend points, making it harder to reason about the code.
Comprehensions
--------------