in reply to Refresh a Module
LanX presented this topic at the Frankfurt Perl Workshop last Sunday and we discussed it. The main point I find missing is, that the redefinitions can only affect code, and not data. This makes the whole thing a non-starter for me, since for example reloading a class/object package will only do what I want if I don't declare new accessors and don't restructure my existing object tree:
my $info = My::Config->new( Load( 'config.yaml' )); # in My::Config package My::Config 0.01 { use Moo 2; has 'include_files' => ( is => 'lazy', default => sub { [] }, ); }; # After update: # in My::Config package My::Config 0.01 { use Moo 2; has 'plugins' => ( is => 'lazy', default => sub { [] }, ); has 'include_templates' => ( is => 'lazy', default => sub { [] }, ); };
If the above happens, you will still have an object $info that looks like:
$info = { include_files => [], };
... but the other code will never access the old data.
I can imagine cases where I want both, blowing away the old data, and keeping the old data, and I think there is no good "automatic" way of determining what I want in each case.
In limited situations, for example where programmer-users are allowed to rewrite some plugin code that gets hot-reloaded, and that plugin code is required to act in a functional way, that is, having no state of its own, reloading a module can still work.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Refresh a Module
by LanX (Saint) on Oct 01, 2024 at 14:11 UTC |