Hacker News new | ask | show | jobs
by contravariant 1858 days ago
For what it's worth Python's yield pretty much is a coroutine, as it has a (very rarely used) feature that allows information from the caller to be passed back to the generator.

The c++ implementation seems closer to lisps 'call with current continuation', though as far as I can tell all implementations achieve more or less the same thing (though thread safety might vary among the options).

Actually continuation passing style (callbacks) are another way of doing the same thing, though they have the disadvantage that they require large structural changes to the code. It wouldn't surprise me if the callback hell can therefore also occur in all versions, though some might make it easier than others (python's implementation in particular makes it somewhat less likely by encouraging information to flow one way)

1 comments

> as it has a (very rarely used) feature that allows information from the caller to be passed back to the generator.

The Twisted library encouraged heavy use of this before Python implemented async/await.

https://twistedmatrix.com/documents/current/core/howto/defer...