News for hackers. Stuff that matters.
Re:Node.js - A Giant Step Backwards by benatkin on Friday August 05, 2011 @03:33AM (#2849300)
Here's a library in JavaSCript that does this. https://github.com/kriszyp/promised-io

The differences between your example and the common JavaScript practice for promises (when they're used; most of the time they aren't) are that then is used instead of addCallback and that chaining is available and taken advantage of.

Re:Node.js - A Giant Step Backwards by thristian on Friday August 05, 2011 @05:41AM (#2849534)
What do you mean by 'chaining'? Twisted's Deferreds provide at least a couple of things one might casually describe as 'chaining'.
Re:Node.js - A Giant Step Backwards by andypants on Friday August 05, 2011 @05:58AM (#2849562)
Instead of:

  d.then(func1);
  d.then(func2);
You can use:

  d.then(func1).then(func2);
Re:Node.js - A Giant Step Backwards by thristian on Friday August 05, 2011 @06:16AM (#2849599)
Ah, yes. Twisted's Deferreds do support that kind of chaining, but I didn't use it in my original snippet because I didn't want to have an example of a Deferred where no Deferreds were actually visible. :)

In my own code, I tend not to use chaining because "methods returning self" is not a common idiom in Python (although tools like jQuery have given it currency in the JS world) and because I haven't yet figured out a way of formatting a multi-line method invocation that doesn't look messy.

Re:Node.js - A Giant Step Backwards by buster on Friday August 05, 2011 @06:12AM (#2849589)
as you can do in twisted ;)