6

I want to be able to hotpatch modules while the program is running for a project I'm working on. I tried this, but it doesn't work:

qx[rm -r .precomp/*];
try require PSBot;
try PSBot.test;

Is it possible to do? If so, how can I do it?

Kaiepi
  • 3,230
  • 7
  • 27

1 Answers1

5

No, they can't. CompUnits, compilation units or installed modules are immutable. You cannot unload a module to load it again, which is what you mean by hotfix.

jjmerelo
  • 22,578
  • 8
  • 40
  • 86
  • 2
    You can't unload, but could you potentially load again with a different version, and have a top level manager module that routed calls to the latest version? You would eventually run into memory problems I guess. – Curt Tilmes Jan 12 '19 at 14:08
  • 3
    Depending on if you want to keep any global state, I guess you could whip up a Perl 6 process that calls another process, which would drop out of that when needed. But that feels more like you'd need an `nginx` frontend with a soft restart on the backend (if you catch my drift) – Elizabeth Mattijsen Jan 12 '19 at 21:58