3 ms·
And it's not even correct. Python's lambda can contain an arbitrary number of lines, as long as they're a single expression. Considering that lambda is "borrowe
by jmillikin 17y ago
And it's not even correct. Python's lambda can contain an arbitrary number of lines, as long as they're a single expression. Considering that lambda is "borrowed" from functional languages, which are inherently single-expression, I've never seen what anybody's problem is with them.
- brehaut 17y agoThe problem is that in functional languages you have a lot of tools build on higher order functions, so you can easily leverage functions as expressions. On the other hand, its standard practice to use statement forms (if, while, for, try etc) to describe a lot of the processing. As statements are not allowed in lambdas this means you either are stuck writing a local named function and writing the code in idiomatic python or writing some helper functions to allow you to write code in a functional but non-idiomatic python style. It comes down to a matter of style. My personal theory is that once a python programmer discovers the magic of itertools they are about 3 months from looking for a new language that supports the functional style more naturally.
- stcredzero 17y agoMulti-line, multi-statement closures are tremendously useful in Smalltalk. They're the "secret sauce" that makes Don't Repeat Yourself easy to pull off. You can use them to implement your own control structures, your own notion of transactions, etc. And all (or most) of the above esoteric hackery looks like ordinary Smalltalk. People are down on I statement Lambdas because they don't do all of the above so well.