On Sat, Jul 12, 2008 at 08:47:32PM -0500, Patrick R. Michaud wrote:
> On Sat, Jul 12, 2008 at 11:05:35AM -0500, Patrick R. Michaud wrote:
> > On Sat, Jul 12, 2008 at 08:50:44AM -0700, chromatic wrote:
> > > On Saturday 12 July 2008 08:06:33 Patrick R. Michaud wrote:
> > > > Short answer: cloning is what will enable the following to work:
> > > > for 1..10 -> $x {
> > > > sub foo() { say $x; }
> > > > push(@foos, &foo);
> > > > }
>
> And I might be able to make the argument that it's nearly
> equivalent to
>
> for 1..10 -> $x {
> our &foo = -> { say $x; }
> push(@foos, &foo);
> }
>
> with the exception that &foo is uninitialized prior to the loop
> in this last version.
... and the exception that our &foo is a cloned closure instead
of an uncloned sub. So, perhaps not. (But the recursive version
still seems mostly identical.)
Pm