A friendlier, sugarier lambda -- a proposal for Ruby-like blocks in python
bearophileHUGS at lycos.com
bearophileHUGS at lycos.com
Sat Oct 14 19:54:44 EDT 2006
Alexey Borzenkov:
> I was so attached to these "nameless" def-forms that I was even shocked
> when I found that this doesn't work in python:
> f = def(a, b):
> return a*b
> Another good feature of Boo, btw.
I think Boo has some good things worth consideration (and maybe worth
to copy) and some bad things that I like less than Python ones.
Turning def and class into functions reduces the need of lambdas
(compared to a lambda the required return is the only thing in the way)
and I like it, but maybe it reduces code readabilty a bit for people
that have just started to program:
mul2 = def(a, b):
return a * b
Instead of:
def mul2(a, b):
return a * b
The lightweight Io language uses an even simpler approach, some
examples:
http://www.iolanguage.com/about/samplecode/
An example:
factorial := method(n, if(n == 1, 1, n * factorial(n - 1)))
The "method" function is used to define functions...
Bye,
bearophile
More information about the Python-list
mailing list