On Mon, 3 Sep 2001, Brent Dax wrote:

> Now is where the temp() stuff I was talking about earlier comes in.
>
>       sub foo {
>               my($bar);
>               foo();
>       }
>
> is basically equivalent to
>
>       sub foo {
>               temp($MY::bar);
>               foo();
>       }

Oh, you're pitching softballs to yourself.  Try a hard one:

  my @numbers;
  for (0 .. 10) {
    my $num = $_;
    push(@numbers, sub { $num });
  }
  for (0 .. 10) {
    local $num = $_;
    push(@numbers, sub { $num });
  }
  print join(', ', map { $_->() } @numbers), "\n";

It's in Perl5, but the analogy to Perl6 should be clear enough.  This is a
good example of the different natures of lexical and dynamic variables.

-sam


Reply via email to