3 ms·
Another approach to async IO is CPS (continuations passing style), in which you write imperative style code. This imperative style code is then compiled such th
by grogs 14y ago
Another approach to async IO is CPS (continuations passing style), in which you write imperative style code. This imperative style code is then compiled such that the blocking IO operations are called with callbacks, which are the remainder of that block of code (the continuation) - allowing the calling thread to be re-used while blocking for IO. Relies on the continuation having access to the outer/parent/previous-part function via closures.
It'll be interesting to see if people start doing this. Requires people to understand continuations and closures (which more people have exposure to now via JavaScript), and library support.
- ambrop7 14y agoHey, that was my idea too, see my own comment [1]. I've actually developed a (very simplistic) programming language utilizing this approach. I even compiled the interpreter to Javascript so you can try it our from the browser. [1] http://news.ycombinator.com/item?id=4736630 http://news.ycombinator.com/item?id=4736630