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 variable. Each closure's $y
> however is different and independent.
>
and what if
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 ?
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?
}
and what does it mean ?
arcadi