Replacement for lambda - 'def' as an expression?
Terry Reedy
tjreedy at udel.edu
Tue Sep 6 15:37:52 EDT 2005
"Sybren Stuvel" <sybrenUSE at YOURthirdtower.com.imagination> wrote in message
news:slrndhr3q6.48f.sybrenUSE at schuimige.unrealtower.org...
> talin at acm dot org enlightened us with:
>> I'd be sad to see the notion of "anonymous functions" go
Though it is as yet unclear as to what may come in compensation.
> Same here. I think it's a beautyful concept
Are you claiming that including a reference to the more humanly readable
representation of a function (its source code) somehow detracts from the
beauty of the function concept? Or are you claiming that binding a
function to a name rather than some other access reference (like a list
slot) somehow detracts from its conceptual beauty? Is so, would you say
the same about numbers?
It seems to me that the beauty of the function concept is quite independent
of its definition syntax and post-definition access method.
>, and very powerful.
If anything, adding a source pointer to a function object makes it more,
not less powerful.
>> What about passing an anonymous function as an argument,
>> which is the most common case?
>
> I don't really like that. The syntax is way too messy.
I agree.
> Just the
> funcref = def(args):
> ...
> syntax would suffice for me.
But this is deficient relative to def funcref(args): ... since the *only*
difference is to substitute a generic tag (like '<lambda>') for a specific
tag (like 'funcref') for the .func_name attribute.
Terry J. Reedy
More information about the Python-list
mailing list