develooper Front page | perl.perl5.porters | Postings from December 2010

Re: [perl #80628] [PATCH] __SUB__

Thread Previous | Thread Next
Florian Ragwitz
December 12, 2010 14:27
Re: [perl #80628] [PATCH] __SUB__
Message ID:
Father Chrysostomos (via RT) <> writes:

> This patch adds a __SUB__ keyword that returns the current subroutine,
> or undef for the main program, a special block, or an eval.

Using '__SUB__' made me think it was a compile-time constant such as
__FILE__ and __LINE__. It isn't, so I think it's not very good naming.

Why not make it look like a regular function or keyword, such as

  sub {
      print "$_[0]\n";
      caller_cv(0)->($_[0] + 1) if $_[0] < $arg;

In fact this is already available on CPAN as Devel::Caller. Is this
something common and useful enough to make it part of the core language?
I'm not really convinced of that.

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About