
On Mon, Sep 16, 2019 at 7:13 PM George Fischhof <george@fischhof.hu> wrote:
yes exactly I would like this.
Regarding the waiting and frameworks:
The solution should be independent from waiting and frameworks:
Let's see what happens now (sync, not async)
User has a generator, he wants values.
Uses a for cycle to process all values from generator: Asks for first value - wait for the value to be computed Processes the value he got Asks for next value - wait for the value to be computed And processes again, and again
The async version:
User has a generator, he wants values, he created an async version, because he wants the values faster
Okay, well that's the problem. An async function won't yield the values faster, and it will not allow two things to happen simultaneously. It just allows I/O and other such operations to happen asynchronously. If you want the values faster, consider instead a second thread or process and a queue; in place of the generator, just read from the queue, which will block until you have something to read. Meanwhile, your other thread/process is generating values and placing them on the queue. What you're asking for is not just a syntactic change - it's a significant semantic change that introduces concurrency in ways that async functions do not currently have. Basically you'd get all the problems of threading, without the advantages of threading. ChrisA