develooper Front page | perl.perl5.porters | Postings from April 2015

Re: Is there a clever way to null out non-void subs?

Thread Previous | Thread Next
April 22, 2015 09:49
Re: Is there a clever way to null out non-void subs?
Message ID:
Tom Christiansen wrote:
>and "retroactively" null it out so that it it ripe for pruning

Retroactive is not so easy, but if you know at compile time of the
call that it's to be nulled out then call checker magic can do that.
There's no problem about it being conditional, as long as the condition
can be resolved no later than compile time of the call.  You need
to either write some XS or use the rather dubious B::CallChecker.
(Using the B toolchain to generate ops is what's really dubious; this
simple case of nulling out a call is reasonably within its capabilities.)

Debug::Show uses precisely this trick, via B::CallChecker.  D:S itself
may satisfy your requirement, and if not then it's a model for you to
follow in writing whatever you actually need.

>Plus you have the problem of wasted evaluation of somebody(42).

To be clear, the nulling that Debug::Show performs does avoid evaluation
of the argument expressions.  It excises the entire sub call optree.


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