justin at justinhileman.info
Sun Dec 8 09:51:48 MST 2013
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:
More information about the PLUG