3 ms·
Adding function literals to Python would be nice. Something to turn "inc = lambda x: x + 1" into "inc = def(x): return x + 1". But blocks? They're a misfeature
by lucian1900 15y ago
Adding function literals to Python would be nice. Something to turn "inc = lambda x: x + 1" into "inc = def(x): return x + 1".
But blocks? They're a misfeature of Ruby, badly copied from Smalltalk.
[edit: added "return"]
- recursive 15y agoIt looks like you changed "lambda" to "def" and added parentheses. It seems like that feature is already there...
- lucian1900 15y agoPerhaps my example was crap. They would also allow anything inside them.
- sirclueless 15y agoThe problem with multiline lambdas it that no one knows a good way to indent them. If they weren't butt-ugly python would probably already have them.
- stcredzero 15y ago"The problem with multiline lambdas in Python is that no one knows a good way to indent them." How about new keyword(s)? "begin" and "end"? I imagine this has thoroughly been discussed ad-nauseum. Is there a good synopsis?
- recursive 15y agoBasically, there is no scope or block ending token anywhere else in python. And Guido thinks inline multi-line anonymous functions make programs harder to understand.
- lucian1900 15y agoI'm not sure it's that big a problem. CoffeeScript handles this pretty well using indentation. CS has ambiguous cases because of optional ( ), but that wouldn't be the case with Python anyway.