in reply to Re: Tail Recursion in Perl
in thread Tail Recursion in Perl

While "goto &sub" is an interesting way to go about this, the cautiousness/conciousness needed in the twiddling of @_, and the oddity of its syntax are not what I am looking for.

I would like to find a way to do this without any actual programmer intervention. Maybe through some kind of post-compilation op-code manipulation. The more I read about the B & Opcode modules and such, it seems like it might be way to complex.

I cooked up a module a while back (after reading a book ML and a few on Erlang), while in some ways it belongs in the obsfucated code section of this site more than anywhere else, I was happy with its (sorta) simplicity/purity of design. While I have never benchmarked it, I know it would never hold up in production.

-stvn

Replies are listed 'Best First'.
Re: Re: Re: Tail Recursion in Perl
by bsb (Priest) on Jan 02, 2004 at 01:01 UTC
Source filters
by sleepingsquirrel (Chaplain) on Jan 04, 2004 at 03:42 UTC
    While "goto &sub" is an interesting way to go about this, the cautiousness/conciousness needed in the twiddling of @_, and the oddity of its syntax are not what I am looking for.
    If a change in the "goto &sub" syntax would meet your requirements, you might have a look at source filters (see also Filter::Simple). At first glance it doesn't seem like it should be too hard to make a macro (call it tail_return) which transforms something like...
    tail_return sub(a,b,c);
    ...into the proper goto syntax.