On Sun Jul 08 02:13:13 2012, thoughtstream wrote:
> Father Chrysostomos pointed out:
>
> > I said when, not whether. :-)
>
> Isn't that just typical of me: confusing ontology with chronology. ;-)
>
> I'm afraid don't know the implementation details for Rakudo. It may be
> bound as the surrounding block is entered, or perhaps just-in-time when
> the Code object is first accessed in some way.
>
>
> > Does Perl 6 have an equivalent to this?
> >
> > my $x;
> > for $x(1..10) {}
>
> In Perl 6 that's:
>
> my $x;
> for 1..10 -> $x {}
>
> And, as in Perl 5, they're two separate variables.
But by using the term ‘variable’, which is ambiguous, you are not
answering my question! :-)
In Perl 5, ‘my $x; for $x(1..10){}’ is only equivalent to ‘my $x; for my
$x(1..10){}’ because we don’t have the := operator, so there is never
any possibility to see the difference, even though things happen
differently underneath.
Does
my $x;
for 1..10 -> $x {}
cause the existing name $x to refer temporarily to each of the numbers,
or is a new $x name created?
What does this do?
my $x;
my sub f { say $x }
for 1..10 -> $x { f(); }
--
Father Chrysostomos