Skip to content

Instantly share code, notes, and snippets.

@cemerick
Created June 18, 2010 13:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cemerick/e9bb4c44adf8d9a195dd to your computer and use it in GitHub Desktop.
Save cemerick/e9bb4c44adf8d9a195dd to your computer and use it in GitHub Desktop.
; (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