One of the things SmallTalk proponents like to brag about his how they can change their source code while it's running. That's pretty cool and I want it for Perl. As a follow-up to yesterday's post on better exception handling, imagine the following scenario.
Your batch process takes four hours to run. Three hours into the run, it throws an exception. An email is sent to the ops team who call you. You log in from home to discover that the program
So at your request, FIXIT fires up an editor with the appropriate source code and you make the necessary changes. You save and are presented with a diff and the ability to reedit the code. Once satisfied, FIXIT installs the subroutine or method and you can ask it to resume execution of the code, rather than starting your four hour run from the top.
Nothing in that scenario is particularly hard, but there are a lot of fiddly bits which wouldn't look quite right (and deparsed coderefs for the editor look just ugly, but they would work).
<>Update: In yesterday's post, both Joshua ben Jore and Salvador Fandiño both point to tools which can handle this (one being 5.9 specific). If this can be done so trivially, why aren't more people using it? I'm confused.Re:It's a mind set thing
Ovid on 2006-10-06T11:03:38
The potentially fatal flaw in the plan:
#!/usr/bin/perl -l
use strict;
use warnings;
a();
a();
sub a {
b();
print 'whoops!';
}
sub b {
no warnings 'redefine';
*a = sub {
b();
print "hi there!";
};
}This is obvious in retrospect. I can't imagine this would be easy to get around.