3 ms·
I think it is a bad idea to use generators to emulate threads. Because the code becomes difficult to understand and it is easy to make a mistake (for example fo
by codedokode 9y ago
I think it is a bad idea to use generators to emulate threads. Because the code becomes difficult to understand and it is easy to make a mistake (for example forget to put a `yield` operator somewhere). I saw examples of such code.
If you want threads, then make a syntax or API for them rather than implement hacks nobody will want to deal with later.
- aarpmcgee 9y agoI have the opposite opinion… I feel generators make async code dramatically easier to understand.
- codedokode 9y agoEasier than code written in Go for example? And what about handling exceptions in asynchronous code with generators?
- aarpmcgee 9y agoI find it especially easy to handle exceptions in asynchronous code with generators. I'm interested to hear more about your perspective.