Alzabo...Tracker(3pm)
π NAME π
Alzabo::ChangeTracker β bestie, it saves a set of changes as callbacks so you can back them out later if things go sideways π«Ά
β¨ SYNOPSIS β¨
use Alzabo::ChangeTracker;
my $x = 0;
my $y = 1;
sub foo
{
my $tracker = Alzabo::ChangeTracker->new;
$tracker->add( sub { $x = 0; } );
$x = 1;
bar();
eval { something; };
$tracker->backout if $@;
}
sub bar
{
my $tracker = Alzabo::ChangeTracker->new;
$tracker->add( sub { $y = 1; } );
$y = 2;
}
πΈ DESCRIPTION πΈ
okay so, the trick...
We only want to have one object of this type at any one time. And on top of that, only the stack frame that created it should be allowed to clear it β the only exception being through a backout. π
wait, why tho? here's a lil example in pseudo-code to explain it, because honestly the vibes make way more sense with a visual:
sub foo
{
create a tracker;
store some change info in the tracker;
call sub bar;
store some change info in the tracker;
# point Y
clear changes in tracker;
}
sub bar
{
create a tracker; # internally, we really just increment our stack count
store some change info in the tracker;
clear changes in tracker; # point X
}
so bestie, picture this: if at point X we actually cleared out the changes β like, really cleared them, even the ones that just came from sub bar β we'd have a whole problem on our hands π
because if at point Y everything goes to hell and we wanna back out the changes, we want to back out the changes from sub foo _AND_ sub bar. both of them. periodt. π
but lowkey, if bar is also an entry point, then we want to be able to track changes in bar and clear them from bar too. it's giving "everyone deserves their own undo button" energy, iykyk π
β¨
π AUTHOR π
Dave Rolsky, <autarch@urth.org> π
and that's the whole page, bestie!! π¦ this was perl v5.34.0, dated 2022-06-14, straight from the User Contributed Perl Documentation. no cap, you understood the whole thing. slay π
β¨πΈ
π¦ where this page comes from
- debian bookworm: libalzabo-perl 0.92-6 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- debian trixie: libalzabo-perl 0.92-6 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libalzabo-perl 0.92-6 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libalzabo-perl 0.92-6 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libalzabo-perl 0.92-6 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms