News for hackers. Stuff that matters.
Re:Fogus: Node.js should become its own language by DTrejo on Tuesday April 12, 2011 @10:49AM (#2437413)
Not sure why he uses this as a code sample, as it's also not how someone would write code (though I suppose he is entitled to his style).

The original from the article

  function do_request(req) {
    return long_io_operation(
    req, 
    callback=function(results) {
      return create_something_from(results);
    });
  }
How it might be written if you saw it in a codebase

  function do_request(req, callback) {
    long_io_operation(req, function(err, results) {
      callback(err, create_something_from(results));
    });
  }
It seems like the article is not finished, so I can understand that there might be questionable sections. Also you'll note that he forgot the `error, results` argument pattern for callbacks, making me think that he is not terribly familiar with node.

There are no comments on this comment yet.