Permalink
Browse files

Allow an object to save itself during finalization.

  • Loading branch information...
1 parent 6f711ed commit 91fb42e6e6f64d085038b3a4d9785e64a36c89b5 @kr committed Mar 26, 2009
Showing with 37 additions and 1 deletion.
  1. +1 −1 reaper.na
  2. +7 −0 sh-tests/fin7.exp
  3. +29 −0 sh-tests/fin7.na
View
@@ -1,8 +1,8 @@
def reaper: sobj:
(run.):
if (is? self.state 'dead):
- self.object.finalize
self.set-state 'finalized
+ self.object.finalize # this may re-register the object
(find.):
if (is? self.state 'dead): return self
View
@@ -0,0 +1,7 @@
+a
+b
+finalized
+c
+d
+finalized
+e
View
@@ -0,0 +1,29 @@
+import reaper
+
+def (make-x.):
+ def o: obj:
+ (finalize.):
+ pr 'finalized
+ x = o
+ reaper.register o
+ o
+
+def x: (make-x.)
+
+reaper.register x
+
+def (dec n):
+ if n < 1: return 'ok
+ dec n - 1
+
+pr 'a
+dec 40000
+pr 'b
+x = '()
+dec 40000
+pr 'c
+dec 40000
+pr 'd
+x = '()
+dec 40000
+pr 'e

0 comments on commit 91fb42e

Please sign in to comment.