eval(readFile("Worlds_Compiled")) array.push = function(x) { this[this.length] = x this.length = this.length + 1 } array.pop = function() { var r = this[this.length - 1] this[this.length - 1] = null this.length = this.length - 1 return r } array.last = function() { return this[this.length - 1] } worldProto.sprout = function() { return this.call(function() { return new world }) } // -------------------------------------------------------------------- seaside = { worlds: [world], perform: function(action) { var w = this.worlds.last().sprout() this.worlds.push(w) return w.call(this[action]) }, back: function() { if (this.worlds.length > 0) this.worlds.pop() }, flattenHistory: function() { while (this.worlds.length >= 2) { var w = this.worlds.pop() w.commit() } } } counter = function() { var count = 0 var me = new seaside() me.inc = function() { return count = count + 1 } return me }() x = "foo" counter.perform("inc") counter.perform("inc") counter.perform("inc") x = "bar" counter.back() counter.perform("inc") x