Hacker News new | past | comments | ask | show | jobs | submit login

They're not different though, right? Just two ways to think about what it means to return, no? How can you return a value without returning control to read that value? They're the same.

Still, I don't think iterators and coroutines are necessarily the same. You can imagine a coroutine that doesn't return a value and only happens to share a thread or something.




Regardless of the underlying mechanism that make them both work, programmers generally have a vastly different conception of yielding (that is, 'producing') a generated value as opposed to yielding (that is, 'ceding') execution time to the OS or a virtual machine.


Right, difference between yield as in "crop yield" and yield as in "yield right of way".


That's the thing, since either one can be implemented in terms of the other, people conflate iterators/generators with coroutines as you've mentioned because they're easily interchangeable.


This is functionally identical to yielding a dummy value. If the language has a unit type (e.g. a 0-ary tuple) then you just use a value of that type.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: