Mark S. Miller (2014-09-11T14:00:34.000Z)
domenic at domenicdenicola.com (2014-09-17T22:17:58.417Z)
VM issues are not the argument against coroutines or deep generators. The issue is that unpredictable interleaving makes reasoning about invariants much too difficult. Without these, we have an important guarantee: When f synchronously calls g, the only side effects that might have occurred by the time g returns to f are those g might have caused. Thus, these are the only side effect possibilities that f must worry about. See section 18.3 of http://www.erights.org/talks/thesis/markm-thesis.pdf and replace postfix diagonal uparrow with prefix "await". In ES7 the example would be async function foo() { return bar(await getint(), y()); } ... await foo() ... The net effect is like co-routines, except that the placement of "async" and "await" -- like the diagonal uparrow in the text -- marks the places where interleaving might occur. This is as close to coroutine support as we should ever come.