A friendlier, sugarier lambda -- a proposal for Ruby-like blocks in python

bearophileHUGS at lycos.com bearophileHUGS at lycos.com
Sun Oct 15 01:54:44 CEST 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
An example:

factorial := method(n, if(n == 1, 1, n * factorial(n - 1)))

The "method" function is used to define functions...


More information about the Python-list mailing list