Hello, when I was reading the PEP, it surprised me that return is not allowed in an async generator. You can transparently decompose an ordinary function, and yield from was added to be able to do the same with generators, so it seems natural to be able to decompose async generators the same way – using (await) yield from and return.
I found the explanation in the section about async yield from, but maybe a link to that section might be added as explanation why return produces a SyntaxError. In ideal world it seems that the transition from ordinary functions to generators and the transition from ordinary functions to async functions (coroutines) are orthogonal, and async gnerators are the natural combination of both transitions. I thing this is true despite the fact that async functions are *implemented* on top of generators. I imagine the situation as follows: being a generator adds an additional output channel – the one leading to generator consumer, and being an async function adds an additional output channel for communication with the scheduler. An async generator somehow adds both these channels. I understand that having the concepts truly ortogonal would mean tons of work, I just think it's pity that something natural doesn't work only because of implementation reasons. However, introducing async generators is an important step in the right way. Thank you for that. Regards, Adam Bartoš
_______________________________________________ Python-ideas mailing list [email protected] https://mail.python.org/mailman/listinfo/python-ideas Code of Conduct: http://python.org/psf/codeofconduct/
