[EMAIL PROTECTED] wrote:
> my $i=0;
> dosomefunnierstuff();
> sub dosomefunnierstuff {
>         my $funnierstuff;
>         if($funnierstuff=~/funnier/) {
>                 dosomefunnierstuff();
>         } else {
>                 $funnierstuff="funnier".$i++;
>         }
>         print "Funnierstuff is $funnierstuff\n";
> }
> 
> That proves the point a bit more clearly.  It will show that each
> layer of the "stack" keeps its own discreet copy of the variable.

Oh, I see what you're talking about.  That's a closure.  It's a language
feature, so changing that behavior would be significant.  This shouldn't
be a problem if you simply avoid using closures in a recursive
algorithm.  In your example, I believe only the value of $i will be
saved each time, since $funnierstuff will go out of scope at the end of
the block and get garbage collected.

- Perrin

Reply via email to