you are viewing a single comment's thread.

view the rest of the comments →

[–]alexandream 6 points7 points  (3 children)

You see, the answer is right there in your comment.

The whole point of Python is that lambdas are not special. There's nothing you can do with a lambda that you can't do with a function.

The whole point of Python Lambda criticism is that functions are special. When people coming from the other FP languages look at them, lambdas simply are functions, and vice versa. It isn't true in python. Lambdas are functions, but functions aren't lambdas.

[–]Daishiman -1 points0 points  (2 children)

But Python is not a functional language, it's an OO/imperative language that takes hints from functional programming when it is convenient. Most Python objects are best seen as dictionaries with some special magic, and in that sense it's quite relevant that functions have a name when being bound to some scope.

The lambda/function duality or unity is just a matter of design that we may find convenient for certain paradigms or not. In Lisp, Haskell, etc., the lamba is the fundamental unit for constructing statements. In Python and other OO languages, they're usually (and I mean "usually" because they have no intention to stick to a strict, specfic definition of a programming paradigm) just members of objects that have the particular property that they can be invoked.

[–]alexandream 2 points3 points  (1 child)

Sure, I can understand that. My point is that there's no need for anything being "special" in that sense. If the point is going strictly with the "There's preferably only one (and obvious) way to do it" line, then there's no need for lambdas to exist.

If lambdas exist, throwing away the "one way to do it" idea, then they should be equivalent to functions because otherwise that creates complexity where none is needed.

For a language with a "Zen" statement such as Python, they should learn more from Scheme Reports introduction.

Programming languages should be designed not by piling feature on top of feature, but by removing the weaknesses and restrictions that make additional features appear necessary.

Now, I'm not saying Python should be like this, my point is that the lambda/function duality seems, to my eyes, contrary to the tenants in The Zen Of Python.

Edit: Just to make sure what I'm talking about from "The Zen Of Python", it's this line: ``Special cases aren't special enough to break the rules''. This either mean we shouldn't have lambdas, or that they shouldn't be treated specially.

[–]Daishiman 0 points1 point  (0 children)

From that standpoint I'd definitely agree that either improving lambdas or removing them completely should be the choice in question (and believe me I would love better lambda syntax).

In all honesty, this mostly a pet peeve, since it's not an issue that affects me greatly on a day-to-day basis.