Python's simplicity philosophy

Hannu Kankaanp?? hanzspam at yahoo.com.au
Fri Nov 21 08:04:54 EST 2003


"Terry Reedy" <tjreedy at udel.edu> wrote in message news:<sIqdnYBZtKIYFiSi4p2dnA at comcast.com>...
> The above was a minimal 'concept' proposal to test the aesthetics of
> something structurally different from current 'lambda's.  I think I
> would make all identifiers params by default, since I believe this to
> be more common, and 'tag' non-locals, perhaps with one of the
> reserved, as yet unused symbols.  Example: lambda x: x + y == `x + @y`
> or `x+y@`.   Since expressions cannot assign, no global declaration is
> needed.

A pretty simplistic way to do something similar would be this alias:

@  <=>  lambda X=None, Y=None, Z=None:

Thusly:

seq.sort(lambda x, y: cmp(y, x))   =>
seq.sort(@cmp(Y, X))

map(lambda x: x[::-1], seq)   =>
map(@X[::-1], seq)

It could replace lambda for most cases. Half of the
function definition wouldn't be "useless trash" anymore,
and redundancy in describing the parameter names would 
go away (lambdas don't usually need describing parameter
names).

But @ isn't exactly describing symbol (though "lambda" or "def"
don't scream out "Here's a function definition!" either)
and the 3 implicit arguments don't really fit with
Python's explicity philosophy.... And from what
I've gathered, Guido would rather remove lambda than
introduce syntax that encourages small anonymous functions
(in a weird way to boot). Oh well.




More information about the Python-list mailing list