]> gitweb.factorcode.org Git - factor.git/commitdiff
continuations[-docs]: add the finally word
authorAlexander Iljin <ajsoft@yandex.ru>
Mon, 22 Apr 2019 14:49:05 +0000 (16:49 +0200)
committerJohn Benediktsson <mrjbq7@gmail.com>
Tue, 23 Apr 2019 04:57:51 +0000 (21:57 -0700)
57 files changed:
basis/concurrency/distributed/distributed.factor
basis/concurrency/locks/locks.factor
basis/concurrency/semaphores/semaphores.factor
basis/db/tuples/tuples.factor
basis/environment/environment.factor
basis/game/input/input.factor
basis/hash-sets/wrapped/prettyprint/prettyprint.factor
basis/hashtables/wrapped/prettyprint/prettyprint.factor
basis/io/directories/unix/unix.factor
basis/io/directories/windows/windows.factor
basis/io/files/info/windows/windows.factor
basis/io/files/unique/unique.factor
basis/io/monitors/monitors.factor
basis/io/servers/servers.factor
basis/listener/listener.factor
basis/logging/server/server.factor
basis/math/floats/env/env.factor
basis/models/models.factor
basis/opengl/framebuffers/framebuffers.factor
basis/opengl/opengl.factor
basis/opengl/shaders/shaders.factor
basis/prettyprint/backend/backend.factor
basis/stack-checker/stack-checker-tests.factor
basis/tools/coverage/coverage.factor
basis/tools/destructors/destructors.factor
basis/tools/profiler/sampling/sampling.factor
basis/ui/backend/gtk/gtk.factor
basis/ui/backend/gtk/io/io.factor
basis/ui/backend/windows/windows.factor
basis/ui/ui.factor
basis/unix/groups/groups.factor
basis/unix/signals/signals-tests.factor
basis/unix/users/users.factor
basis/unix/utmpx/utmpx.factor
basis/vocabs/refresh/refresh-tests.factor
basis/windows/com/com.factor
basis/windows/privileges/privileges.factor
basis/windows/registry/registry.factor
basis/x11/x11.factor
basis/x11/xim/xim.factor
core/alien/alien.factor
core/compiler/units/units.factor
core/continuations/continuations-docs.factor
core/continuations/continuations.factor
core/destructors/destructors.factor
core/effects/parser/parser.factor
core/io/files/files-tests.factor
extra/compiler/cfg/gvn/testing/testing.factor
extra/cuda/contexts/contexts.factor
extra/cuda/gl/gl.factor
extra/curses/curses.factor
extra/graphviz/graphviz-tests.factor
extra/graphviz/render/render.factor
extra/managed-server/managed-server.factor
extra/mason/build/build.factor
extra/odbc/odbc.factor
extra/tools/image-analyzer/utils/utils.factor

index 9f480362ec67514589a2155c7a68f0eadbc41d5e..7e59a4ef79c6938e644a32255cb94ff30639dd3e 100644 (file)
@@ -60,7 +60,7 @@ C: <connection> connection
     [ stream>> dispose ] [ drop ] if ;
 
 : with-connection ( remote-thread quot -- )
-    '[ connect @ ] over [ disconnect ] curry [ ] cleanup ; inline
+    '[ connect @ ] over [ disconnect ] curry finally ; inline
 
 : send-remote-message ( message node -- )
     binary [ serialize ] with-client ;
index 9e56c0425309ffee69d39e5d9dc8cfe5f9459f39..69c6c8b4f8cc73f40a3c18b460dd297a00321d1a 100644 (file)
@@ -27,7 +27,7 @@ TUPLE: lock threads owner reentrant? ;
 
 :: do-lock ( lock timeout quot acquire release -- )
     lock timeout acquire call
-    quot lock release curry [ ] cleanup ; inline
+    quot lock release curry finally ; inline
 
 : (with-lock) ( lock timeout quot -- )
     [ acquire-lock ] [ release-lock ] do-lock ; inline
index 392b7557d69e21a5e3f4198986e4f55b0256c1fa..11196b4f499933bf758e32b3ffd2b201952810ab 100644 (file)
@@ -32,7 +32,7 @@ M: negative-count-semaphore summary
 
 :: with-semaphore-timeout ( semaphore timeout quot -- )
     semaphore timeout acquire-timeout
-    quot [ semaphore release ] [ ] cleanup ; inline
+    quot [ semaphore release ] finally ; inline
 
 : with-semaphore ( semaphore quot -- )
-    swap dup acquire '[ _ release ] [ ] cleanup ; inline
+    swap dup acquire '[ _ release ] finally ; inline
index e4422eea89334a2b69d28f0d6759241bca6918d2..bb8000828b7485194f0bc70b6224f7e998b93efb 100644 (file)
@@ -48,7 +48,7 @@ GENERIC: eval-generator ( singleton -- object )
 
 : with-disposals ( object quotation -- )
     over sequence? [
-        over '[ _ dispose-each ] [ ] cleanup
+        over '[ _ dispose-each ] finally
     ] [
         with-disposal
     ] if ; inline
index 79c83733a3bfd59713952748ef1c772eb514864e..f945d2933c516da43a40767382547e84c5647ed8 100644 (file)
@@ -27,7 +27,7 @@ HOOK: set-os-envs-pointer os ( malloc -- )
 
 : with-os-env ( value key quot -- )
     over [ [ [ set-os-env ] 2curry ] [ compose ] bi* ] dip
-    [ os-env ] keep [ set-os-env ] 2curry [ ] cleanup ; inline
+    [ os-env ] keep [ set-os-env ] 2curry finally ; inline
 
 {
     { [ os unix? ] [ "environment.unix" require ] }
index e46587f5bad5b5c658eeb1bbc3e05dc7751e2941..f36bc212e314a4db9a61d7d2a6e48d7a24f2d209 100644 (file)
@@ -59,7 +59,7 @@ ERROR: game-input-not-open ;
     ] unless ;
 
 : with-game-input ( quot -- )
-    open-game-input [ close-game-input ] [ ] cleanup ; inline
+    open-game-input [ close-game-input ] finally ; inline
 
 TUPLE: controller handle ;
 TUPLE: controller-state x y z rx ry rz slider pov buttons ;
index 265f758580de98bad0946bfd244f29986d29ec59..810be0c91a27878ea275f84fecc1c70cdfb93818 100644 (file)
@@ -10,4 +10,4 @@ M: wrapped-hash-set >pprint-sequence members ;
 
 M: wrapped-hash-set pprint*
     nesting-limit inc
-    [ pprint-object ] [ nesting-limit dec ] [ ] cleanup ;
+    [ pprint-object ] [ nesting-limit dec ] finally ;
index 1abd5cc10a7058037610bc43dda6dfb97076c671..cf4100e44ddcee6a8a62df447d7e214f7ab4d118 100644 (file)
@@ -10,4 +10,4 @@ M: wrapped-hashtable >pprint-sequence >alist ;
 
 M: wrapped-hashtable pprint*
     nesting-limit inc
-    [ pprint-object ] [ nesting-limit dec ] [ ] cleanup ;
+    [ pprint-object ] [ nesting-limit dec ] finally ;
index 14a37f5bedf2fd5802527f6273fd63d69bc51ce8..2b989fe501b164d3fdb36d1082f89c2d5e11685d 100644 (file)
@@ -42,7 +42,7 @@ M: unix copy-file ( from to -- )
 : with-unix-directory ( path quot -- )
     dupd '[ _ _
         [ opendir dup [ throw-errno ] unless ] dip
-        dupd curry swap '[ _ closedir io-error ] [ ] cleanup
+        dupd curry swap '[ _ closedir io-error ] finally
     ] with-directory ; inline
 
 : dirent-type>file-type ( type -- file-type )
index 93a7d6f9697be8cf681553a927d4c727fe5ae81d..ec7615677582415c24de59e4d1c3a1ca77b6631d 100644 (file)
@@ -84,4 +84,4 @@ M: windows (directory-entries) ( path -- seq )
             produce nip
             over name>> "." = [ nip ] [ swap prefix ] if
         ]
-    ] [ drop '[ _ FindClose win32-error=0/f ] ] 2bi [ ] cleanup ;
+    ] [ drop '[ _ FindClose win32-error=0/f ] ] 2bi finally ;
index 702d83245415456e369e19bb963f8ea06053580b..71f8e06f695203f415f5c2c9ccca3d87dc388a23 100644 (file)
@@ -194,7 +194,7 @@ CONSTANT: names-buf-length 16384
             [ _ find-next-volume dup ] [ ] produce nip
             swap prefix
         ]
-    ] [ '[ _ FindVolumeClose win32-error=0/f ] ] bi [ ] cleanup ;
+    ] [ '[ _ FindVolumeClose win32-error=0/f ] ] bi finally ;
 
 ! Windows may return a volume which looks up to path ""
 ! For now, treat it like there is not a volume here
index 93ad08cc7a2b35c967e4b71bc0852a3acfbe2d69..9a2647a52e492aa039d605fb84b0f93f4fd8fe05 100644 (file)
@@ -50,11 +50,11 @@ PRIVATE>
 
 :: cleanup-unique-file ( ..a prefix suffix quot: ( ..a path -- ..b ) -- ..b )
     prefix suffix unique-file :> path
-    [ path quot call ] [ path delete-file ] [ ] cleanup ; inline
+    [ path quot call ] [ path delete-file ] finally ; inline
 
 :: cleanup-unique-files ( ..a prefix suffixes quot: ( ..a paths -- ..b ) -- ..b )
     prefix suffixes unique-files :> paths
-    [ paths quot call ] [ paths [ delete-file ] each ] [ ] cleanup ; inline
+    [ paths quot call ] [ paths [ delete-file ] each ] finally ; inline
 
 : unique-directory ( -- path )
     [
@@ -70,7 +70,7 @@ PRIVATE>
 :: cleanup-unique-directory ( quot -- )
     unique-directory :> path
     [ path quot with-directory ]
-    [ path delete-tree ] [ ] cleanup ; inline
+    [ path delete-tree ] finally ; inline
 
 {
     { [ os unix? ] [ "io.files.unique.unix" ] }
index c0286f594d1797fcd5720ad28c49e2a0589e4fa5..6891f9983f0f7b5601011118516852aeac78d20d 100644 (file)
@@ -16,7 +16,7 @@ M: object dispose-monitors ;
 : with-monitors ( quot -- )
     [
         init-monitors
-        [ dispose-monitors ] [ ] cleanup
+        [ dispose-monitors ] finally
     ] with-scope ; inline
 
 TUPLE: monitor < disposable path queue timeout ;
index b25cb22c110fd326fbc7804af9120d045a1be0c8..c603d144c69c58608959e50426d964e6e9367bb3 100644 (file)
@@ -211,7 +211,7 @@ PRIVATE>
     '[
         [ _ threaded-server _ with-variable ]
         [ _ stop-server ]
-        [ ] cleanup
+        finally
     ] call ; inline
 
 <PRIVATE
index 46806b5404781e38af974784beb210bc142b6432..b308ab5947ee1485643b6d92292b1f98ca4490c8 100644 (file)
@@ -33,7 +33,7 @@ SYMBOL: handle-ctrl-break
     ! Always call disable-ctrl-break, no matter what handle-ctrl-break
     ! says: it might've been changed just now by the user in the Listener.
     ! It's a no-op if it's not enabled.
-    [ disable-ctrl-break ] [ ] cleanup ; inline
+    [ disable-ctrl-break ] finally ; inline
 
 : parse-lines-interactive ( lines -- quot/f )
     [ [ parse-lines ] with-ctrl-break ] with-compilation-unit ;
index b9d8cf78f171eb2088548011698c78cfee768db5..8240dcc26e0a1bb44fa4cead93696cd048a28afa 100644 (file)
@@ -33,7 +33,7 @@ SYMBOL: log-files
     [ close-log-streams path \ log-root set-global quot call ]
     \ log-root get-global
     [ \ log-root set-global close-log-streams ] curry
-    [ ] cleanup ; inline
+    finally ; inline
 
 : timestamp-header. ( -- )
     "[" write now (timestamp>rfc3339) "] " write ;
index df6328729e383432bc163cafe789904e8a73de1a..c86f97c5f4f33697f06798ce3217463bb0286f2d 100644 (file)
@@ -134,14 +134,14 @@ PRIVATE>
 :: with-denormal-mode ( mode quot -- )
     denormal-mode :> orig
     mode set-denormal-mode
-    quot [ orig set-denormal-mode ] [ ] cleanup ; inline
+    quot [ orig set-denormal-mode ] finally ; inline
 
 : rounding-mode ( -- mode ) fp-env-register (get-rounding-mode) ;
 
 :: with-rounding-mode ( mode quot -- )
     rounding-mode :> orig
     mode set-rounding-mode
-    quot [ orig set-rounding-mode ] [ ] cleanup ; inline
+    quot [ orig set-rounding-mode ] finally ; inline
 
 : fp-traps ( -- exceptions )
     (fp-env-registers) [ (get-fp-traps) ] [ union ] map-reduce >array ; inline
@@ -150,7 +150,7 @@ PRIVATE>
     clear-fp-exception-flags
     fp-traps :> orig
     exceptions set-fp-traps
-    quot [ orig set-fp-traps ] [ ] cleanup ; inline
+    quot [ orig set-fp-traps ] finally ; inline
 
 : without-fp-traps ( quot -- )
     { } swap with-fp-traps ; inline
index 6d3a9a9e83241323667430cf448c26028641cc0e..0fa5f2079e54ea9a4a43c5cd50f83eb9c1899d71 100644 (file)
@@ -68,7 +68,7 @@ GENERIC: model-changed ( model observer -- )
 : with-locked-model ( model quot -- )
     [ '[ _ t >>locked? @ ] ]
     [ drop '[ f _ locked?<< ] ]
-    2bi [ ] cleanup ; inline
+    2bi finally ; inline
 
 GENERIC: update-model ( model -- )
 
index 3eb3705d0c2819bce0d9f0db4adbce3fee440053..18027e18c30c5db779a54d1fe323c4cf770b5dd1 100644 (file)
@@ -37,7 +37,7 @@ IN: opengl.framebuffers
 
 : with-framebuffer ( id quot -- )
     [ GL_DRAW_FRAMEBUFFER swap glBindFramebuffer ] dip
-    [ GL_DRAW_FRAMEBUFFER 0 glBindFramebuffer ] [ ] cleanup ; inline
+    [ GL_DRAW_FRAMEBUFFER 0 glBindFramebuffer ] finally ; inline
 
 : with-draw-read-framebuffers ( draw-id read-id quot -- )
     [
@@ -47,7 +47,7 @@ IN: opengl.framebuffers
     [
         GL_DRAW_FRAMEBUFFER 0 glBindFramebuffer
         GL_READ_FRAMEBUFFER 0 glBindFramebuffer
-    ] [ ] cleanup ; inline
+    ] finally ; inline
 
 : framebuffer-attachment ( attachment -- id )
     GL_FRAMEBUFFER swap GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME
index 53887994d4735b8c2ff6d49fe1318e239b5a0649..b261d59c5884116bd591cc266ac9d4c1ee849598 100644 (file)
@@ -174,7 +174,7 @@ MACRO: all-enabled-client-state ( seq quot -- quot )
 
 :: with-gl-buffer ( binding id quot -- )
     binding id glBindBuffer
-    quot [ binding 0 glBindBuffer ] [ ] cleanup ; inline
+    quot [ binding 0 glBindBuffer ] finally ; inline
 
 : with-array-element-buffers ( array-buffer element-buffer quot -- )
     [ GL_ELEMENT_ARRAY_BUFFER ] 2dip '[
@@ -189,7 +189,7 @@ MACRO: all-enabled-client-state ( seq quot -- quot )
 
 :: with-vertex-array ( id quot -- )
     id glBindVertexArray
-    quot [ 0 glBindVertexArray ] [ ] cleanup ; inline
+    quot [ 0 glBindVertexArray ] finally ; inline
 
 : <gl-buffer> ( target data hint -- id )
     pick gen-gl-buffer [
index a4a21880e7c10c1b0ca2e3104252363fe4d9f01c..22086b986d47d62ac6fbeb7cf56873e753ff4fc1 100644 (file)
@@ -114,7 +114,7 @@ PREDICATE: fragment-shader < gl-shader (fragment-shader?) ;
     ] each glDeleteProgram ;
 
 : with-gl-program ( program quot -- )
-    over glUseProgram [ 0 glUseProgram ] [ ] cleanup ; inline
+    over glUseProgram [ 0 glUseProgram ] finally ; inline
 
 PREDICATE: gl-program < integer (gl-program?) ;
 
index 0fd99e7e0b39c586a2899f7755cc478d9fb22463..e2f58de6e25387c8d1bf867c5eebac391edc4f41 100644 (file)
@@ -266,7 +266,7 @@ M: byte-vector pprint* pprint-object ;
 
 : with-extra-nesting-level ( quot -- )
     nesting-limit [ dup [ 1 + ] [ f ] if* ] change
-    [ nesting-limit set ] curry [ ] cleanup ; inline
+    [ nesting-limit set ] curry finally ; inline
 
 M: hashtable pprint*
     [ pprint-object ] with-extra-nesting-level ;
index 267245daedc65e9584f34e5b4404d3574201e285..792d209bdea2da1d19ac2f83f8cfe9d6e1bd2ad7 100644 (file)
@@ -246,7 +246,7 @@ DEFER: blah4
 ! Test words with continuations
 { 0 0 } [ [ drop ] callcc0 ] must-infer-as
 { 0 1 } [ [ 4 swap continue-with ] callcc1 ] must-infer-as
-{ 2 1 } [ [ + ] [ ] [ ] cleanup ] must-infer-as
+{ 2 1 } [ [ + ] [ ] finally ] must-infer-as
 { 2 1 } [ [ + ] [ 3drop 0 ] recover ] must-infer-as
 
 ! A typo
index 5854deeee6e24f7e019c78ab09f4ec2887a5a72f..bfcabbc98c0551735092609a9ba630af3daceead 100644 (file)
@@ -126,7 +126,7 @@ PRIVATE>
                 _
                 [ coverage-on test-vocab coverage-off ]
                 [ coverage ] bi
-            ] [ _ remove-coverage ] [ ] cleanup
+            ] [ _ remove-coverage ] finally
         ] call
     ] bi ;
 
index 36cecc35e8147a70f312705c1f530b1dfabad428..452cb29fd2f465a7d525ba8e03c0de1e1565afc8 100644 (file)
@@ -47,7 +47,7 @@ PRIVATE>
     t debug-leaks? set-global
     [
         [ call disposables get clone ] dip
-    ] [ f debug-leaks? set-global ] [ ] cleanup
+    ] [ f debug-leaks? set-global ] finally
     diff ; inline
 
 : leaks. ( quot -- )
index b6aa596823fa5a3a4abf075b9b2b875da43faa37..c0ba754fe9ab88eb54313ba7bd3fcaa6b9c91394 100644 (file)
@@ -30,7 +30,7 @@ PRIVATE>
 : profile ( quot -- )
     samples-per-second get-global profiling
     [ 0 profiling (get-samples) raw-profile-data set-global ]
-    [ ] cleanup ; inline
+    finally ; inline
 
 : total-sample-count ( sample -- count ) 0 swap nth ;
 : gc-sample-count ( sample -- count ) 1 swap nth ;
index fb7cee86e9b8e23690aed399dfdd2f9073121ad7..f3a78aa79b9556c221d23890a34259ec0d137ffc 100644 (file)
@@ -80,7 +80,7 @@ M: gtk-clipboard set-clipboard-contents
     source G_PRIORITY_DEFAULT_IDLE g_source_set_priority
     source f g_source_attach drop
     [ quot call( -- ) ]
-    [ source g_source_destroy ] [ ] cleanup ;
+    [ source g_source_destroy ] finally ;
 
 ! User input
 
index 577a05f1f46cf3cadb00517a4eb098b6974c90b8..4e661c6a91d7e6e81427bc4b2c980f66d0572e91 100644 (file)
@@ -48,4 +48,4 @@ CONSTANT: poll-fd-events
     [
         source g_source_destroy
         start-io-thread
-    ] [ ] cleanup ;
+    ] finally ;
index 7431ddb4c9722982d1fbe81a4ff3af02392de677..ab21fb7936654b2a839bfe8269afd64d253aff13 100644 (file)
@@ -704,7 +704,7 @@ M: windows-ui-backend (with-ui)
         init-win32-ui
         start-ui
         event-loop
-    ] [ cleanup-win32-ui ] [ ] cleanup ;
+    ] [ cleanup-win32-ui ] finally ;
 
 M: windows-ui-backend beep
     0 MessageBeep drop ;
index 43af6f6c815862683d6b71d268bcc0bde10ce3ad..347def51fe0e4af97cf9571445cebe96d41f27db 100644 (file)
@@ -228,7 +228,7 @@ M: object resize-window 2drop ;
             f ui-running set-global
             ! Give running ui threads a chance to finish.
             notify-ui-thread yield
-        ] [ ] cleanup
+        ] finally
     ] if ;
 
 HOOK: beep ui-backend ( -- )
index b43f8d43acd63c783af4e00a8af8d5a8a487728e..92cf9f258fbf115bddf49cc8c1b1d876eecd1418 100644 (file)
@@ -115,14 +115,14 @@ GENERIC: set-effective-group ( obj -- )
 
 : (with-real-group) ( string/id quot -- )
     '[ _ set-real-group @ ]
-    real-group-id '[ _ set-real-group ] [ ] cleanup ; inline
+    real-group-id '[ _ set-real-group ] finally ; inline
 
 : with-real-group ( string/id/f quot -- )
     over [ (with-real-group) ] [ nip call ] if ; inline
 
 : (with-effective-group) ( string/id quot -- )
     '[ _ set-effective-group @ ]
-    effective-group-id '[ _ set-effective-group ] [ ] cleanup ; inline
+    effective-group-id '[ _ set-effective-group ] finally ; inline
 
 : with-effective-group ( string/id/f quot -- )
     over [ (with-effective-group) ] [ nip call ] if ; inline
index 43de224cfd3f1832a984c66bf7d69004c1309e3d..f09f6dee18906affaeb2392b4a638de0ddc07261 100644 (file)
@@ -23,7 +23,7 @@ test-sigusr1-handler SIGUSR1 add-signal-handler
         swap -
     ] unit-test
 
-] [ test-sigusr1-handler SIGUSR1 remove-signal-handler ] [ ] cleanup
+] [ test-sigusr1-handler SIGUSR1 remove-signal-handler ] finally
 
 { 0 } [
     sigusr1-count get-global
index ee2e592c1f452b0da224939534178bdb2d14e8bd..7b77eebefeb8debeb073189e6d5be67d5a7e44f9 100644 (file)
@@ -32,7 +32,7 @@ M: unix passwd>new-passwd ( passwd -- seq )
 
 : with-pwent ( quot -- )
     setpwent
-    [ unix.ffi:endpwent ] [ ] cleanup ; inline
+    [ unix.ffi:endpwent ] finally ; inline
 
 PRIVATE>
 
@@ -94,7 +94,7 @@ GENERIC: set-effective-user ( string/id -- )
 : (with-real-user) ( string/id quot -- )
     '[ _ set-real-user @ ]
     real-user-id '[ _ set-real-user ]
-    [ ] cleanup ; inline
+    finally ; inline
 
 : with-real-user ( string/id/f quot -- )
     over [ (with-real-user) ] [ nip call ] if ; inline
@@ -102,7 +102,7 @@ GENERIC: set-effective-user ( string/id -- )
 : (with-effective-user) ( string/id quot -- )
     '[ _ set-effective-user @ ]
     effective-user-id '[ _ set-effective-user ]
-    [ ] cleanup ; inline
+    finally ; inline
 
 : with-effective-user ( string/id/f quot -- )
     over [ (with-effective-user) ] [ nip call ] if ; inline
index 6e78f12671a5bc3e39b27be31006156eee0a4567..c61f88d8c76e10e8bbab10747dca148ec5b7b06e 100644 (file)
@@ -38,7 +38,7 @@ M: unix new-utmpx-record
     utmpx-record new ;
 
 : with-utmpx ( quot -- )
-    setutxent [ endutxent ] [ ] cleanup ; inline
+    setutxent [ endutxent ] finally ; inline
 
 : all-utmpx ( -- seq )
     [
index 61363aa2d759670c9524599e41f2ce024518ebe1..03ae27bf3dc0f584381b1ff7e494f13f8db45850 100644 (file)
@@ -4,5 +4,5 @@ USING: vocabs.refresh tools.test continuations namespaces ;
     changed-vocabs get-global
     f changed-vocabs set-global
     { t } [ "kernel" changed-vocab? ] unit-test
-    [ "kernel" changed-vocab ] [ changed-vocabs set-global ] [ ] cleanup
+    [ "kernel" changed-vocab ] [ changed-vocabs set-global ] finally
 ] unit-test
index 4334eda29df7b9294d38a575fd39934c63c58a7d..a4b759adf856f5715e53a4e1c026327aa266c579 100644 (file)
@@ -111,6 +111,6 @@ ERROR: null-com-release ;
     [ IUnknown::Release drop ] [ null-com-release ] if* ; inline
 
 : with-com-interface ( interface quot -- )
-    over [ com-release ] curry [ ] cleanup ; inline
+    over [ com-release ] curry finally ; inline
 
 DESTRUCTOR: com-release
index e04dfa016a0c4ac73978852184c867b1ec70c836..1d124fcbfa8ac5de7d8f699043bd6474a52cf9d6 100644 (file)
@@ -25,7 +25,7 @@ TYPEDEF: TOKEN_PRIVILEGES* PTOKEN_PRIVILEGES
     ! quot: ( token-handle -- token-handle )
     [ open-process-token ] dip
     [ keep ] curry
-    [ CloseHandle drop ] [ ] cleanup ; inline
+    [ CloseHandle drop ] finally ; inline
 
 : lookup-privilege ( string -- luid )
     [ f ] dip LUID <struct>
@@ -52,4 +52,4 @@ TYPEDEF: TOKEN_PRIVILEGES* PTOKEN_PRIVILEGES
 : with-privileges ( seq quot -- )
     [ '[ _ [ t set-privilege ] each @ ] ]
     [ drop '[ _ [ f set-privilege ] each ] ]
-    2bi [ ] cleanup ; inline
+    2bi finally ; inline
index 03d2228abfe60616218fe1d6a771630fbed63c85..be9109827605f58e38fb9b0bb72f8b367a152131 100644 (file)
@@ -55,13 +55,13 @@ CONSTANT: registry-value-max-length 16384
     key subkey mode open-key :> hkey
     [ hkey quot call ]
     [ hkey close-key ]
-    [ ] cleanup ; inline
+    finally ; inline
 
 :: with-create-registry-key ( key subkey quot -- )
     key subkey create-key :> hkey
     [ hkey quot call ]
     [ hkey close-key ]
-    [ ] cleanup ; inline
+    finally ; inline
 
 <PRIVATE
 
index c1b5ea5c68763df8745c90e3adbc1b85719e58b4..f2cf99a77707ecc9a829a35238654d36f201a3da 100644 (file)
@@ -31,6 +31,6 @@ SYMBOL: root
 : close-x ( -- ) dpy get XCloseDisplay drop ;
 
 : with-x ( display-string quot -- )
-    [ init-x ] dip [ close-x ] [ ] cleanup ; inline
+    [ init-x ] dip [ close-x ] finally ; inline
 
 { "x11" "io.backend.unix" } "x11.io.unix" require-when
index 0f8bd482002a4f5d1d356801009cbf3f3502d977..db64d916e0c5125c29114a7ee198176ed04fd443 100644 (file)
@@ -21,7 +21,7 @@ SYMBOL: xim
     xim get-global XCloseIM drop f xim set-global ;
 
 : with-xim ( quot -- )
-    [ "Factor" init-xim ] dip [ close-xim ] [ ] cleanup ; inline
+    [ "Factor" init-xim ] dip [ close-xim ] finally ; inline
 
 : create-xic ( window classname -- xic )
     [
index 9940151b61e6f2e70f792ebb50e92f8fbc03f20e..f1762e170099444127d9ea681a122ce5f7fff74a 100644 (file)
@@ -131,7 +131,7 @@ PRIVATE>
     [ callbacks get delete-values ] [ free-callback ] bi ;
 
 : with-callback ( alien quot -- )
-    over [ unregister-and-free-callback ] curry [ ] cleanup ; inline
+    over [ unregister-and-free-callback ] curry finally ; inline
 
 : initialize-alien ( symbol quot -- )
     swap dup get-global dup recompute-value?
index dbcea5bf41a2602a484b0997fc5b29081bff6c10..a458ff6fbb0eb77f43414614fbab6697b08c4301 100644 (file)
@@ -198,7 +198,7 @@ PRIVATE>
         [
             remove-nesting-observer
             finish-compilation-unit
-        ] [ ] cleanup
+        ] finally
     ] with-variables ; inline
 
 : with-compilation-unit ( quot -- )
index b54f6ff6c7337dd52c2f1df5f146c3a501d5a4b5..7c5fcaa0722587febbb54c91e5826d8cda1835d1 100644 (file)
@@ -169,12 +169,16 @@ HELP: throw
 { $values { "error" object } }
 { $description "Saves the current continuation in the " { $link error-continuation } " global variable and throws an error. Execution does not continue at the point after the " { $link throw } " call. Rather, the innermost catch block is invoked, and execution continues at that point." } ;
 
-{ cleanup recover } related-words
+{ cleanup recover finally } related-words
 
 HELP: cleanup
 { $values { "try" { $quotation ( ..a -- ..a ) } } { "cleanup-always" { $quotation ( ..a -- ..b ) } } { "cleanup-error" { $quotation ( ..b -- ..b ) } } }
 { $description "Calls the " { $snippet "try" } " quotation. If no error is thrown, calls " { $snippet "cleanup-always" } " without restoring the data stack. If an error is thrown, restores the data stack, calls " { $snippet "cleanup-always" } " followed by " { $snippet "cleanup-error" } ", and rethrows the error." } ;
 
+HELP: finally
+{ $values { "try" { $quotation ( ..a -- ..a ) } } { "cleanup-always" { $quotation ( ..a -- ..b ) } } }
+{ $description "Same as " { $link cleanup } ", but with empty " { $snippet "cleanup-error" } " quotation. Useful when some cleanup code needs to be run after the " { $snippet "try" } " quotation whether an error was thrown or not, but when nothing specific needs to be done about any errors." } ;
+
 HELP: recover
 { $values { "try" { $quotation ( ..a -- ..b ) } } { "recovery" { $quotation ( ..a error -- ..b ) } } }
 { $description "Calls the " { $snippet "try" } " quotation. If an exception is thrown in the dynamic extent of the " { $snippet "try" } " quotation, restores the data stack and calls the " { $snippet "recovery" } " quotation to handle the error." } ;
index 63a704a07f2649927a2ecc93a58d2e00a810ff08..bf32960d0f979fcd147f6b035619f73ce8da5257 100644 (file)
@@ -162,6 +162,9 @@ callback-error-hook [ [ die rethrow ] ] initialize
 : cleanup ( try cleanup-always cleanup-error -- )
     [ compose [ dip rethrow ] curry recover ] [ drop ] 2bi call ; inline
 
+: finally ( try cleanup-always -- )
+    [ ] cleanup ; inline
+
 ERROR: attempt-all-error ;
 
 : attempt-all ( ... seq quot: ( ... elt -- ... obj ) -- ... obj )
index 9571d0fb1b141c144c6eb82694934c47db1401f1..c50435fed10a9f7ba965559b9758aa8643385b4e 100644 (file)
@@ -59,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
 
index 75fdf63d279689f3cd5188f9cb65b0a30dc7e43f..f10ca77afd1d1de7b69ad7bef97e9d27358c3b46 100644 (file)
@@ -77,7 +77,7 @@ ERROR: can't-nest-definitions word ;
     manifest get current-vocab>> t or in-definition delete ;
 
 : with-definition ( quot -- )
-    [ set-in-definition ] prepose [ unset-in-definition ] [ ] cleanup ; inline
+    [ set-in-definition ] prepose [ unset-in-definition ] finally ; inline
 
 : (:) ( -- word def effect )
     [
index 4024e5ed5c3008febeaa57f2c88f22b1a5dae614..6893424f172dc2aa4e578ef450e350f57e7edf08 100644 (file)
@@ -274,7 +274,7 @@ CONSTANT: pt-array-1
     [
         "resource:core" normalize-path
         [ cwd = ] [ cd ] [ cwd = ] tri
-    ] cwd '[ _ dup cd cwd = ] [ ] cleanup
+    ] cwd '[ _ dup cd cwd = ] finally
 ] unit-test
 
 { t } [
index 73e7fe060a9fca9737b332373b2e7fd4c0e55666..3d0f68fc7a083e1af1df62117617670204205fa1 100644 (file)
@@ -93,14 +93,14 @@ SYMBOL: iteration
     ] with-variable ;
 
 : watch-gvn ( path quot -- )
-    annotate-gvn [ test-gvn ] [ reset-gvn ] [ ] cleanup ;
+    annotate-gvn [ test-gvn ] [ reset-gvn ] finally ;
 
 : watch-gvn-cfg ( path cfg -- )
     annotate-gvn [
         { value-numbering } passes [
             0 iteration [ watch-cfg ] with-variable
         ] with-variable
-    ] [ reset-gvn ] [ ] cleanup ;
+    ] [ reset-gvn ] finally ;
 
 : watch-gvn-bb ( path insns -- )
     0 test-bb 0 get block>cfg watch-gvn-cfg ;
index 175a35143c58849e9ba577d268305985edf07ed0..b3cab931cbac012dc9d401cd5fc88181b55cad55 100644 (file)
@@ -28,7 +28,7 @@ DESTRUCTOR: destroy-context
 DESTRUCTOR: clean-up-context
 
 : (with-cuda-context) ( context quot -- )
-    swap '[ _ clean-up-context ] [ ] cleanup ; inline
+    swap '[ _ clean-up-context ] finally ; inline
 
 : with-cuda-context ( device flags quot -- )
     [ set-up-cuda-context create-context ] dip (with-cuda-context) ; inline
index a4257c2dbbc1c295a811fd451283fadc4871619d..9b71d7dec48bec1559bf52964eaacec33931469d 100644 (file)
@@ -39,7 +39,7 @@ DESTRUCTOR: unmap-resource
 DESTRUCTOR: free-resource
 
 : with-mapped-resource ( ..a resource quot: ( ..a device-ptr size -- ..b ) -- ..b )
-    over [ map-resource ] 2dip '[ _ unmap-resource ] [ ] cleanup ; inline
+    over [ map-resource ] 2dip '[ _ unmap-resource ] finally ; inline
 
 TUPLE: cuda-buffer
     { buffer buffer }
index a6629650ad107cd92250d7f3a2ee70fd2eae7448..3e4eb3e1fd2eb3778f6ecd45dd2785fd77e331f3 100644 (file)
@@ -277,7 +277,7 @@ PRIVATE>
             init-colors
 
             _ with-window
-        ] [ ffi:endwin curses-error ] [ ] cleanup
+        ] [ ffi:endwin curses-error ] finally
     ] with-destructors ; inline
 
 <PRIVATE
index b5b58fb465de572b58ebc67b4f9a9efff012cf1b..70be570456b80edd394eb3c12348cfd452e0b50e 100644 (file)
@@ -232,7 +232,7 @@ SYMBOLS: supported-layouts supported-formats ;
 :: with-global-value ( value variable quot -- )
     variable get-global "orig" [
         [ value variable set-global quot call ]
-        [ "orig" get variable set-global ] [ ] cleanup
+        [ "orig" get variable set-global ] finally
     ] with-variable ; inline
 
 : preview-format-test ( format -- pass? )
index ea077a15ecb95ebd8c33f356c95250d09756298c..ddbba2e7720a843c62c56d2e979a833353c48a99 100644 (file)
@@ -82,7 +82,7 @@ PRIVATE>
         graph dot-file ?encoding write-dot
         dot-file format layout try-graphviz-command
     ]
-    [ dot-file ?delete-file ] [ ] cleanup ;
+    [ dot-file ?delete-file ] finally ;
 
 : graphviz* ( graph path format -- )
     default-layout get-global graphviz ;
index e60a5b24fd46272e97ea394ad3a91d830b306ac0..a8070abbbfb2359dda01c819270b92c0bacae39d 100644 (file)
@@ -95,7 +95,7 @@ M: managed-server handle-client*
     managed-server namespaces:set
     [ handle-managed-client ]
     [ cleanup-client ]
-    [ ] cleanup ;
+    finally ;
 
 : new-managed-server ( port name encoding class -- server )
     new-threaded-server
index 567075498bf0834d1721a82bd66aa00e85903222..217d22626948222970865cb0680834f5c2f53f23 100644 (file)
@@ -48,7 +48,7 @@ IN: mason.build
         ] bi
         notify-finish
         finish-build
-    ] [ cleanup-build ] [ ] cleanup
+    ] [ cleanup-build ] finally
     notify-idle ;
 
 MAIN: do-build
index 935d9e0bae94ef66c18ba9f4d07ff132cd021f82..f7bfa4d87c00bdcc1917e4de007cb246ee16605e 100644 (file)
@@ -279,4 +279,4 @@ C: <field> field
             dup odbc-get-all-rows
             swap odbc-free-statement
         ] keep
-    ] [ odbc-disconnect ] [ ] cleanup ;
+    ] [ odbc-disconnect ] finally ;
index 981a7e4658aed756af2b7fa0975f8abb34af427e..5bfca098c4597300fcf4b6a3beac058a8701e0b2 100644 (file)
@@ -29,7 +29,7 @@ IN: tools.image-analyzer.utils
     ] ; inline
 
 : save-io-excursion ( quot -- )
-    tell-input '[ _ seek-absolute seek-input ] [ ] cleanup ; inline
+    tell-input '[ _ seek-absolute seek-input ] finally ; inline
 
 : consume-stream>sequence ( reader-quot: ( -- item )  -- seq )
     until-eof-reader '[ drop @ ] t swap follow rest ; inline