News for hackers. Stuff that matters.
Re:Ruby-style Blocks in Python by russell on Sunday March 08, 2009 @03:47PM (#507461)
This style takes care of 90 or 99% of the cases. If you have to pass 2 or more functions, revert to using named functions. The 'there' proposal that I mentioned before allows for arbitrary placement of the anonymous function, IIRC. If not, usage patterns will adjust to the new idiom.
Re:Ruby-style Blocks in Python by sah on Sunday March 08, 2009 @05:32PM (#507551)
You might say by the same argument that single-line lambda expressions take care of 90 or 99% of cases, and you should revert to using named functions for the rest.

I don't think either is true -- if you have more flexibility in the syntax, you'll do more with it.

Re:Ruby-style Blocks in Python by russell on Sunday March 08, 2009 @08:52PM (#507740)
The reason for all the discussion over the years is that a single line lambda doesn't cover 90% of the cases. If you think in terms of callbacks, I bet one liner cover less than 10% of the cases.
Re:Ruby-style Blocks in Python by anewaccountname on Sunday March 08, 2009 @09:56PM (#507806)
Python already has a solution for callbacks:

    @reg_callback(button.onclick)
    def callback():
        do_stuff()
Re:Ruby-style Blocks in Python by jamongkad on Monday March 09, 2009 @06:12AM (#508206)
Whilst this is more pythonic I personally prefer Javascripts use of lambdas as more than a means of expression. More like a way of life for the language :-) And that is IMHO what makes it functionally closer to Scheme. Just looking at the way one defines lambdas in Javascript and their use throughout the language is a thing of beauty.