Sub::Recursive

Sub::Recursive offers anonymous memory leak free recursive subroutines.
Download

Sub::Recursive Ranking & Summary

Advertisement

  • Rating:
  • License:
  • Perl Artistic License
  • Price:
  • FREE
  • Publisher Name:
  • Johan Lodin
  • Publisher web site:
  • http://search.cpan.org/~lodin/Text-Outdent-0.01/lib/Text/Outdent.pm

Sub::Recursive Tags


Sub::Recursive Description

Sub::Recursive offers anonymous memory leak free recursive subroutines. Sub::Recursive offers anonymous memory leak free recursive subroutines.SYNOPSIS use Sub::Recursive; # LEAK FREE recursive subroutine. my $fac = recursive { my ($n) = @_; return 1 if $n < 1; return $n * $REC->($n - 1); }; # Recursive anonymous definition in one line, plus invocation. print recursive { $_ ($_ - 1) } -> (5); # Experimental interface use Sub::Recursive qw/ mutually_recursive %REC /; my ($odd, $even) = mutually_recursive( odd => sub { $_ == 0 ? 0 : $REC{even}->($_ - 1) }, even => sub { $_ == 0 ? 1 : $REC{odd }->($_ - 1) }, );Recursive closures suffer from a severe memory leak. Sub::Recursive makes the problem go away cleanly and at the same time allows you to write recursive subroutines as expression and can make them truly anonymous. There's no significant speed difference between using &recursive and writing the simpler leaking solution. Requirements: · Perl


Sub::Recursive Related Software