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
From:
Zefram
Date:
April 22, 2015 09:49
Subject:
Re: Is there a clever way to null out non-void subs?
Message ID:
20150422094939.GM12971@fysh.org
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.

-zefram

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About