Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

If it has generators it will make it easier. I remember being happy about finding out Twisted has inlineCallbacks. I basically let you not have to split your logical function into multiple functions simply because it has to to do some IO.

Before it used to be code like:

    def processShoppingCart(...):
       d.addCallback(_cb1)
       return d # (d is a Deferred)

   def _cb1(...):
      d2.addCallback(_cb2)
      return d2 # d2 is a another Deferred
etc.

Which with generators and inlineCallbacks turns into

    @someDecoratorThatEnableUsingInlineCallbacks
    def processShoppingCart(...):
       .. do some work ..
       yield <some_io_function_like_check_db>
       .. do some more work ..
       yield <some_io_other_io_function>
       ....
You get the idea. I am not too familiar with Node.js but I imagine it will help quite a bit.


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: