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.


In reply to Re: Refresh a Module by Corion
in thread Refresh a Module by Timka

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.