The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

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

SYNOPSIS

    sub fact {
        my ( $n, $accum ) = @_;

        $accum ||= 1;

        if ( $n == 0 ) {
            return $accum;
        } else {
            recur( $n - 1, $n * $accum );
        }
    }

DESCRIPTION

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.

SEE ALSO

Sub::Call::Tail

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

VERSION CONTROL

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

AUTHOR

Yuval Kogman

COPYRIGHT & LICENSE

        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.