Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- A macro that should work as a try-catch clause. It should take some argument/s and return a value or an exception. If the code opened something it should be closed in the finally clause.
- PROBLEM: (def v (try_catch [s (FileReader. (File "C:/text.txt"))] (. s read)))
- CompilerException java.lang.RuntimeException: Unable to resolve symbol: s in this context, compiling:(NO_SOURCE_PATH:1:58)
- (defmacro try_catch [bindings & code]
- (if (list? bindings)
- `(try
- ~bindings
- (catch Throwable e# e#))
- `(try
- ~code
- (catch Throwable e# e#)
- (finally (. ~@code close)))))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement