From: Steven D'Aprano on
On Wed, 17 Feb 2010 12:39:30 -0600, John Bokma wrote:

> Jonathan Gardner <jgardner(a)jonathangardner.net> writes:
>
>> Then I looked at a stack trace from a different programming language
>> with lots of anonymous functions. (I believe it was perl.)
>>
>> I became enlightened.
>
> If it was Perl [1], I doubt it. Because line numbers are reported, and
> if that doesn't help you, you can annotate anonymous functions with a
> nick name using
>
> local *__ANON__ = 'nice name';
[...]
> As you can see, and a line number is generated, and the nice name is
> shown.

Given that it has a nice name, what makes it an anonymous function?

It seems to me that Perl effectively has three ways of creating
functions, one anonymous and two named (even if one syntax for creating a
named function is almost identical to the syntax for creating an
anonymous function). Once you annotate a function with a nickname, it's
no different from giving it a name.

If this is the case, then your answer to "anonymous functions are a PITA"
is "don't use anonymous functions", which exactly the same answer we'd
give here in Python land. The only difference is that Perl provides two
ways of making a named function, and Python only one[1].






[1] Technically, you can make named functions with the new module and a
bit of work, so Python has two ways too.


--
Steven