On Saturday, December 7, 2013, Eric Wald wrote: > On Dec 7, S. Dale Morrey wrote: > > One thing that I admit I am struggling with, is the idea of functions not > > returning values. Obviously, this isn't a limitation in the language > > itself and more a matter of style. But it seems like most of the libs I'm > > working with want me hand them a function (pointer?) to call back rather > > than returning a value. That works fine for asynchronous code. However > > there are many times I just plain need the code to block and wait for a > > return value, then do something with that value. I don't want to have to > > create a new function just to deal with every single value I need. > > Callback programming like this is hard to wrap your head around, but > it's the simplest way to handle asynchronous events. You're not alone > in considering it somehow backwards; the Twisted framework takes its > name from the brain warping required to do it right. >
+1 to everything Eric said. It's spot on. That said, there is a better way to do this than nesting callbacks for days: http://blog.parse.com/2013/01/29/whats-so-great-about-javascript-promises/ --j -- http://justinhileman.com /* PLUG: http://plug.org, #utah on irc.freenode.net Unsubscribe: http://plug.org/mailman/options/plug Don't fear the penguin. */