On Feb 17, 10:39 am, John Bokma <j...@castleamber.com> wrote: > Jonathan Gardner <jgard...@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
Ok so sonetimes I'm looking at a stack trace and sometimes I can tell what the bug is just by lookong at the function namess. But if it has just line numbers I have to dig through my code looking for the line. > and > if that doesn't help you, you can annotate anonymous functions with a > nick name using > > local *__ANON__ = 'nice name'; > > Finding an issue, and not looking for a solution is not called becoming > enlightened ;-) The issue is that a stacktrace showing a bunch of nameless line numbers can be a bad idea, not that Perl might be deficient (and we already know that in any case), so it's not good to use a lot of them. Anyway once you annotate an anonymous function, it's no longer anonymous. > ~$ perl -e ' > use Carp; > > my $anon = sub { local *__ANON__ = "hello, world"; croak "oops"; }; > $anon->(); > ' > > oops at -e line 4 > main::hello, world() called at -e line 5 > > As you can see, and a line number is generated, and the nice name is > shown. > > If you generate anonymouse functions on the fly based on parameters, you > can encode this into the nice name, of course. > > Sadly, often bold statements about a language are made in ignorance. I don't see what he said was any kind of a bold statement about a language, arguably it was about the coding style. That Perl allows annotating functions doesn't mean people do it. Carl Banks > > [1] perl is the program that executes Perl programs ;-). > > -- > John Bokma j3b > > Hacking & Hiking in Mexico - http://johnbokma.com/http://castleamber.com/- > Perl & Python Development -- http://mail.python.org/mailman/listinfo/python-list