[David Eppstein]
> Basically, every time you run a function that you want to be undoable,
> you call the undo manager with the function that would be used to undo
> it. The undo manager remembers these calls and performs them later when
> undos are requested. It does redos by similarly remembering the calls
> that would be used to undo what happened while it was doing an undo.
> In practice this leads to very concise and straightforward looking code
> that handles infinite levels of undo.
Fascinating. IIRC, Undo is covered as an example in the GoF Patterns book.
I wonder, though, would Undo be handled even more simply as an Aspect? That
is, rather than having to stuff some special incantation into the innards of
every function that you want to undo-enable, an Aspect Oriented Programming
approach would involve specifying the candidates for undo (I think this is
what join points are all about?) and then the special undo magic would Just
Happen (tm)?
I think the challenge with doing AOP in Python is deciding when/how you
define your join points.
(I'm hoping someone who actually knows something about AOP responds with
something more substantive than my vague wonderings. <wink>)
Cheers,
// m
-