in reply to •Re: Is it possible to distinguish contstants from normal subs?
in thread Is it possible to distinguish contstants from normal subs?

That's disappointing. Perl certainly distinguishes (DB::sub isn't called when they're used, for example) so why shouldn't Perl programmers be able to?

Dumb idea: could I compile a bit of code and then examine it with B::Utils to figure out if the sub in question is a constant? Hmmmm, don't see why not...

-sam

  • Comment on Re: •Re: Is it possible to distinguish contstants from normal subs?

Replies are listed 'Best First'.
Re: Re: •Re: Is it possible to distinguish contstants from normal subs?
by chromatic (Archbishop) on May 19, 2002 at 04:44 UTC
    If it's optimized out, probably not. I'd try an experiment with B::Deparse to see what the optree looks like.
      I think it should be possible, but I got stumped trying to figure out how to get the starting OP from an eval"". If I can do that then I can run a simple B::Utils::opgrep() and look for an entersub OP. If there is one, then the subroutine isn't a constant.

      -sam