Ruby programmers love blocks. When Apple added blocks to Objective-C and then to C, it made Cocoa/Cocoa Touch programming a lot easier. So it's only natural that people keep suggesting that blocks should be added to Python, right?

Wrong. Blocks are not a feature, they're a workaround for three serious problems: In Ruby, Objective-C, and C, functions are not first-class objects, they don't capture closures, and they can't be defined inline.

JavaScript, for example, doesn't have any of those problems. You can define functions inline, they capture from the local scope, and they're first-class objects that can be passed around. And its functions can do everything blocks can, and more.
18
Blog Archive
About Me
About Me
Loading
Dynamic Views theme. Powered by Blogger. Report Abuse.