"Persistence" implies that data will be saved and loaded from disk, to a database, or some other persistent storage. That's not what the module does, so I think it needs a new name.
Lexical::Persistence objects are closures that make the values of lexical variables stick (or persist) in everything they call. In the following example, the Lexical::Persistence object makes sure that getter()'s version of $x contains the value stored by setter().
use Lexical::Persistence;
my $lp = Lexical::Persistence->new();
$lp->call(\&setter);
$lp->call(\&getter);
sub setter { my $x = "some value" }
sub getter { print my $x, "\n" }
Lexical::Persistence's closures are objects. Programs may examine and manipulate their contents between calls. The following code displays something like this:
My mind is going. I can feel it.
My is going. I can feel it.
My is going. I feel it.
My going. I feel it.
My going. I feel
My I feel
My I
My
Here's the example:
use Lexical::Persistence;
my $lp = Lexical::Persistence->new();
$lp->set_context(
_ => {
'@mind' => [qw(My mind is going. I can feel it.)]
}
);
while (1) {
$lp->call(\&display);
my $mind = $lp->get_context("_")->{'@mind'};
splice @$mind, rand(@$mind), 1;
last unless @$mind;
}
sub display {
my @mind;
print "@mind\n";
}
So, what would be a better name for this module?
I've got some words for you (Score:2)
You need a word that's not so heavy as "persistent", which is also already in use with a different meaning, as you say.
So, here are some words for you:
My favorite is "sticky", which has a very informal feel about it.
Also, you may want to try out the Reverse Dictionary Lookup [onelook.com], throw some words at it, and see how you like the alternative words that it comes up with.
Lexical::Environment (Score:1)
Lexical::Environment
rjbs