Damian Conway writes:
on the second thought : its quite strange ( though cute ) that
currently the only way to make lexical persistent variable is based on
garbage collector. it is referenced -- hence it is kept.
may be it have to be more explicit like that
sub counter(){
daemon $s; #( or : my $s is daemon; )
INIT{ $s = 0 } ; # ???
$s++;
}
or
sub counter()
will have { BigInt $s } # "have" actually populate attributes of
# the associated "daemon" object
will init { $s = 0 } # sort of constructor for the daemon
{
$s++;
}
I think that something like
daemon $s ;
makes it clear that $s keeps its value somwere in the "shadow" .
arcadi