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

Transforming functional or imperative code into continuation-passing style isn't that big a deal. If javascript weren't such a pain in the ass just to parse, there would probably be tools to do that. Maybe coffeescript will do it, but this is why macro-extensible languages are a big win—I'd have the right hooks to easily do it myself rather than waiting for the implementors to officially update the language (or get elbow deep in their internals and hope they accept a huge patch).

There's already a branch of CoffeeScript, called Iced CoffeeScript (http://maxtaco.github.com/coffee-script/), that does this. The example in the post would look like:

  for blogPostId in recentBlogPostIds
    await asynchronousDB.getBlogPostById blogPostId, defer(err, post)
    templating.render post
Though you still can't simply return the result — you'd have to use a continuation — but it does make it simple enough to use CPS in general.

Guidelines | FAQ | Support | API | Security | Lists | Bookmarklet | DMCA | Apply to YC | Contact