develooper Front page | perl.perl5.porters | Postings from July 2012

Tail recursion optimisation considered possible

Thread Next
From:
demerphq
Date:
July 13, 2012 04:12
Subject:
Tail recursion optimisation considered possible
Message ID:
CANgJU+W_EXtoVhkYLGLAP=pnqofTU3r9-EfSKqmmOUSoEFuuHQ@mail.gmail.com
A comment by one of my colleagues made me realize that now that we
have __SUB__ keyword we can do a limited form of
tail-recursion-optimization.

Basically if a subroutine qualifies as "tail recursive" we can check
to see if the __SUB__ points at the same function as the function
calls resolves to.

If they are the same we can avoid the stack manipulation and replace
the sub call by @_ munging and goto.

Yves


-- 
perl -Mre=debug -e "/just|another|perl|hacker/"

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