Special keyword argument lambda syntax
Beni Cherniavsky
beni.cherniavsky at gmail.com
Sat Mar 14 13:48:09 EDT 2009
On Mar 14, 5:30 pm, Nick Craig-Wood <n... at craig-wood.com> wrote:
> BeniCherniavsky<beni.cherniav... at gmail.com> wrote:
> > This proposal outrageously suggests a special syntax for in-line
> > functions passed as keyword arguments::
>
> > >>> sorted(range(9), key(n)=n%3)
> > [0, 3, 6, 1, 4, 7, 2, 5, 8]
>
> > The claim is that such specialization hits a syntax sweet spot, and
> > that this use case is frequent enough to contemplate eventually making
> > it the only in-line function syntax.
>
> -1 from me.
>
> I think thatlambda/ inline functions should be discouraged as it
> moves python away from, "there should be one-- and preferably only one
> --obvious way to do it." IMHO Guido was right in his original impulse
> to kill this second class way of making functions...
>
On a second thought, considering the LL(1) problem (which indicates a
real problem for humans parsing it) and the "f(x)==" confusion, I
agree.
Given that ``lambda`` usage is negligible compared to ``def`` (1.5% in
python3.0 stdlib, ~3% counting most Python files in ubuntu
repository), it should have been killed altogether per YAGNI and the
"one way" principle.
[Or is it just my "if you don't do it my way, don't do it at all"
emotion talking? Don't know. But I did the statistics only after
formulating the proposal, and I think now that 3% is definitely
YAGNI.]
More information about the Python-list
mailing list