4 ms·
I'm curious about this sentiment about python lambdas. What about them is not real?
by boomlinde 12y ago
I'm curious about this sentiment about python lambdas. What about them is not real?
- facepalm 12y agoIt's been a while, but doesn't it have restrictions, like you can only use it for one liners? Edit: found this via Google - "lambda functions can not contain commands, and they can not contain more than one expression"
- boomlinde 12y ago> and they can not contain more than one expression I don't believe that is different from e.g. scheme. Ideally, a lambda expression would look like a normal function body, but I definitely wouldn't discount them as "not real" on this basis.
- facepalm 12y agoIirc in scheme you can put anything into a lambda that you want. Of course the Python lambda is "real", the correct word to use would have been "limited" I suppose.
- maxerickson 12y agoI suspect much of it is a conflation of the properties of anonymous functions with the properties of first class functions. People see first class functions implemented as lambdas and end up focusing on the wrong part of it (rather than fully understanding what is going on). I realize that more powerful anonymous functions can make for prettier code, but Python's single expression anonymous functions cover an awful lot of the situations where making a name would make the code substantially uglier.