-
-
Save cemerick/e9bb4c44adf8d9a195dd to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; (1) ok, this obviously shouldn't work, and doesn't (sanity check) | |
(loop [continue true] | |
(when continue | |
(try | |
(recur false) | |
(catch Throwable t | |
(recur false)) | |
(finally | |
(println "finally"))))) | |
#<CompilerException java.lang.UnsupportedOperationException: Cannot recur from catch/finally (NO_SOURCE_FILE:12)> | |
; (2) recur is allowed out of the try block, but the finally | |
; is *not* run! This should either work, or don't allow a | |
; recur *out* of any part of a try/catch/finally. | |
(loop [continue true] | |
(when continue | |
(try | |
(recur false) | |
(finally | |
(println "finally"))))) | |
nil | |
; (3) now, this works (sanity-check) | |
(loop [continue true] | |
(when continue | |
(try | |
(dotimes [x 2] (println "hello")) | |
(finally | |
)))) | |
hello | |
hello | |
nil | |
; (4) but it looks like the catch/finally check doesn't take | |
; the recur target into consideration. This should definitely work, | |
; though I feel like this has been raised before...? | |
(loop [continue true] | |
(when continue | |
(try | |
(finally | |
(dotimes [x 2] (println "hello")))))) | |
#<CompilerException java.lang.UnsupportedOperationException: Cannot recur from catch/finally (NO_SOURCE_FILE:33)> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment