http://www.perlmonks.org?node_id=866927


in reply to Re: Re: Re: (Perl6) Groking Continuations (iterators)
in thread (Perl6) Groking Continuations

Perl can do something that closely resembles an optimized tail call, but it only does so if you tell it to.
sub tail_fact { my ($num, $k) = @_; return $k->(1) unless ($num); @_ = ($num - 1, sub { return $num * $k->(shift); }); goto &tail_fact; }