Matthijs van Duin writes:
>
> >does it mean that this is legitimate
> >
> > sub a {
> > state $x;
> > my $y;
> > state sub b { state $z ; return $x++ + $y++ + $z++ ; }
> > return &b; # is a \ before &b needed?
> > }
>
> No, since you can't refer to $y in that s
On Sat, Mar 22, 2003 at 10:24:09PM +0200, arcadi shehter wrote:
sub a {
state $x;
my $y;
my sub b { state $z ; return $x++ + $y++ + $z++ ; }
return &b; # is a \ before &b needed?
}
will all &b refer to the same $z ?
yes, they will
does it mean that this is legitimate
su
Matthijs van Duin writes:
>
> A nice example is:
>
> sub a {
> state $x;
> my $y;
> my sub b { return $x++ + $y++; }
> return &b; # is a \ before &b needed?
> }
>
> Every call to sub a will return a different closure. The $x in
> each closure all refer to the same
On Sat, Mar 22, 2003 at 09:45:43PM +0200, arcadi shehter wrote:
in this example
sub a {
state $x ;
my $y ;
my sub b { ... } ;
...
}
how "my sub b" is different from "state $x" from the point of view of
scope ?
Actually, all three have the same scope, but they have different lifet
Larry Wall writes:
>
> I think it's also a mistake to give C two unrelated meanings.
> These are not lexically-scoped variables any more than "our"
> variables are, and the fact that they can happen accidentally in
> Perl 5 as persistent lexically scoped variables is, er, accidental.
> They