Vorlath should look at Seaside, and the concept of Continuations. Bottom line - been there, done that.
Something else I just can't understand is why source code doesn't have rollbacks. Let's say I allocate an object, then I open a file, but then some kind of error happens on the third statement. How many times do we have code in C (or any other language) to check for allocation, then check for NULL on the file and delete the previously allocated object if the open file command did return NULL and so on getting bigger and bigger. We need a rollback command. Some kind of code attached to all sorts of commands so that it can go back to a previous state. Rollback code for allocation should be deallocation. Rollback code for opening a file should be to close it. Most of this should be default and supplied by the library. So if an error happens, we can rollback to a more stable state. And all this should be hidden away from normal view. If you want to change the way it works, then fine. But it shouldn't clutter the main code. It boggles the mind how backwards we are when it comes to programming. Databases have it. Why not code?