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.
this brings to the following : every subroutine may have a
"daemon" object of some sort associated with it , which will keep
state of the subroutine. so every subroutine is a method of its
"daemon" object . actually , one can think of any subroutine that way
, whatever the way the persistency of these
variables is actually realized.
it seems that there have to be a clear visual
difference between "my" variables and
these "daemon" varibles.
so :
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 is an attribute of an object associated with
that subroutine.
and subroutine may be probably replaced by "closure"
Class Foo {
our $a ;
my $b ;
daemon $c ;
}
arcadi