Michele Dondi <[EMAIL PROTECTED]> writes:

> I must say I've still not read all apocalypses, and OTOH I suspect
> that this could be done more or less easily with a custom function
> (provided that variables will have a method to keep track of their
> history, or, more reasonably, will be *allowed* to have it), but I
> wonder if Perl6 may include a builtin undo() function to recover
> values prior, say, to the last assignement (or push() or,
> etc. etc.[*])

Hmmm...

If we have $foo.undo(), then we will want a multi-step undo to go with
it, probably $foo.undo($n), with $n able to be negative for redo.  Are
we prepared to give the mouse that cookie?  (This is not intended as a
rhetorical question; I suspect people will stake out both positions.)

I heard a rumour we were getting continuations (a la Scheme).  They
wouldn't be tied to a specific variable like what you propose, but
they would allow the state of the entire process to be rolled back to
an earlier point, or something along those lines.  Of course, the
overhead issues are different.  You don't have to start keeping delta
data just because a continuation _might_ be taken; you keep it when a
continuation _has_ been created, and then you use it if the
continuation is ever called (or such is my limited understanding).

With .undo() you would have to keep all the delta data all the time if
.undo() is used at all.  You could try to only keep it for specific
variables that are used with .undo(), but that probably falls apart if
references are brought into the mix.

Could be *mightily* inefficient with RAM.  Of course, you only take
that hit if you ever use .undo()

You could make the programmer specify which variables he wants delta
data for, and then any *others* wouldn't keep it and wouldn't be
undoable.

use undo <<foo bar baz>>; # Or use the funny characters I can't type.
my $foo++;  $foo.undo();  # Undoes the increment.
my $quux++; $quux.undo(); # Throws an exception or something.

-- 
$;=sub{$/};@;=map{my($a,$b)=($_,$;);$;=sub{$a.$b->()}}
split//,"[EMAIL PROTECTED]/ --";$\=$ ;-> ();print$/

Reply via email to