8 ms·
Node.js 0.11 supports generators, which appear to be very similar to what you're describing: http://blog.stevensanderson.com/2013/12/21/experiments-with-koa-and
by ben336 13y ago
Node.js 0.11 supports generators, which appear to be very similar to what you're describing: http://blog.stevensanderson.com/2013/12/21/experiments-with-koa-and-javascript-generators/ http://blog.stevensanderson.com/2013/12/21/experiments-with-...
- gcr 13y agoSimilar, but less general. Serializable continuations can be saved to disk. You can reinstate a completed continuation (eg. go back from the final page. After clicking the link again, the page completes again. Or try clicking the link in several tabs; the page concurrently completes several times as you expect.) Generators make this pattern impossible; Continuations give it to you for free. Second, by being saved on disk, they aren't crammed up in the event loop so they aren't a RAM leak. Racket even provides a way of having the client store all state if you wish; such "stateless" continuations have no memory or disk overhead on a long-running server and never expire until you change your site's source code.
- gcr 13y agoIn short: Generators are useful when you use callbacks to wait for the server to finish doing something (eg. finish a DB update or an HTTP request) Continuations are useful when you're waiting for the user to finish doing something (eg. an HTTP response, not a request). So they do solve different problems.