On Tue, Aug 21, 2001 at 06:06:06PM +0100, Dave Mitchell wrote: > Piers Cawley <pdcawley@iterative-software.com> wrote: > > > { > > > my $x = "bar"; > > > sub foo { > > > # $x # <- uncommenting this line changes the outcome > > > return sub {$x}; > > > } > > > } > > > print foo()->(); > > > > Well, I would expect it to output 'foo' on both occasions, and I'm > > more than a little surprised to discover that it doesn't. Looks like a > > bug to me. > > Using the notation $outer:x, $foo:x and $anon:x to refer to whatever > $x might be in the 3 scopes: > > With the $x: > > foo() is a closure created at compile time. Actually, foo() is not a closure. A closure is an anonymous subroutine and foo() clearly has a name. Now, if you were proposing that named subroutines should behave like closures in this regard, which is what Piers and probably most others were expecting, I suspect that you would probably get broad agreement. -- Paul Johnson - paul@pjcj.net http://www.pjcj.netThread Previous | Thread Next