
Sub::Call::Recur - Self recursive tail call invocation.

sub fact {
my ( $n, $accum ) = @_;
$accum ||= 1;
if ( $n == 0 ) {
return $accum;
} else {
recur( $n - 1, $n * $accum );
}
}

This module implements Clojure's recur special form.
recur is a tail call to the current function. It is a bit like assigning the arguments to @_ and invoking a goto to the first expression of the subroutine.
It can be thought of as the redo operator, but for subroutines instead of loops.
This form allows functional style looping with constant stack space.

B::Hooks::OP::Check::EntersubForCV

http://github.com/nothingmuch/Sub-Call-Recur

Yuval Kogman

Copyright (c) 2009 Yuval Kogman. All rights reserved
This program is free software; you can redistribute
it and/or modify it under the same terms as Perl itself.