|
Re: The fate of reduce() in Python 3000
|
Posted: Mar 18, 2005 2:00 AM
|
|
I think that these (reduce/lambda) should be viewed as two separate issues:
1. map/reduce/filter primitives, and 2. lambda.
If we take as a maxim that a feature should be provided once in the core language then there isn't any issue about the group 1 - list comprehensions do provide the feature, and if someone will miss the syntax, he can always define the corresponding functions himself.
Lambda, however, is different beast IMHO - because it allows you to define a closure without having to name it - that is something a nested function does not provide though they will both end up in a semantically equivalent closure object. And since python treats functions as first class objects (or perhaps 0.99 class objects? :-), it is a feature which has its justification. If you are allowed to write directly foo(X,Y) instead having to write a, b = X, Y foo(a,b)
for any object in python (OK, almost any), why should there be an exception for functions [well, there already is, as lambda does not provide everything a nested function does - but then removing lambda is not solving the problem either :-)]
Sure it can be used to write ugly code, but there isn't a single feature in any language, which could not be banned on that premise :-), and it is also possible to devise examples where anonymous functions will improve code clarity/readability.
|
|