// This example illustrates how worlds may be used to implement Krishna's "versioning exceptions". eval(readFile("Worlds_Compiled")) w = new world try { in w { // Do stuff that will be rolled back if an exception is thrown. x = 5 throw "argh!" } } catch (e) { // Handle the exception (the try block will have had no effect). alert("an exception was thrown!") // Null out w to signal (that way the finally knows its changes should not be committed). w = null } finally { // If the try block did not throw an exception, commit w's changes. if (w != null) w.commit() }