]> gitweb.factorcode.org Git - factor.git/blobdiff - core/destructors/destructors.factor
core: trim using lists with lint.vocabs tool
[factor.git] / core / destructors / destructors.factor
old mode 100755 (executable)
new mode 100644 (file)
index 716f91c..1ed1ce8
@@ -1,8 +1,7 @@
 ! Copyright (C) 2007, 2010 Doug Coleman, Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: accessors assocs continuations init kernel make
-namespaces sequences sets ;
-FROM: namespaces => set ;
+USING: accessors assocs continuations kernel namespaces
+sequences sets ;
 IN: destructors
 
 SYMBOL: disposables
@@ -20,7 +19,7 @@ SLOT: continuation
     disposables get adjoin ;
 
 : unregister-disposable ( obj -- )
-    disposables get 2dup in? [ delete ] [ drop already-unregistered ] if ;
+    dup disposables get ?delete [ drop ] [ already-unregistered ] if ;
 
 PRIVATE>
 
@@ -60,7 +59,7 @@ M: disposable dispose
     [ last rethrow ] unless-empty ;
 
 : with-disposal ( object quot -- )
-    over [ dispose ] curry [ ] cleanup ; inline
+    over [ dispose ] curry finally ; inline
 
 <PRIVATE
 
@@ -83,21 +82,21 @@ PRIVATE>
     dup error-destructors get push ; inline
 
 : with-destructors ( quot -- )
-    [
-        V{ } clone always-destructors set
-        V{ } clone error-destructors set
+    H{ } clone
+    V{ } clone always-destructors pick set-at
+    V{ } clone error-destructors pick set-at [
         [ do-always-destructors ]
         [ do-error-destructors ]
         cleanup
-    ] with-scope ; inline
+    ] with-variables ; inline
 
-[
+STARTUP-HOOK: [
     HS{ } clone disposables set-global
     V{ } clone always-destructors set-global
     V{ } clone error-destructors set-global
-] "destructors" add-startup-hook
+]
 
-[
+SHUTDOWN-HOOK: [
     do-always-destructors
     do-error-destructors
-] "destructors" add-shutdown-hook
+]