Hi I have this school project that I am almost done with so I don't need help with the code, problem is I've never coded in clojure but for this assignment had to do a try and catch macro in clojure with bound forms, there are some REPL commands that are expected to give different responses for the assignment to pass,,
Anyways Im getting an error that I've been googling but nothing is specific to this problem and most explanations basically need there own explanation nothing seems to be beginner adapted so it doesnt do much for me.
(defmacro safe [bindings & code]
(if (list? bindings)
`(try
~bindings
(catch Throwable except# except#))
(if (= (count bindings) 0)
`(try ~code
(catch Throwable except# except#))
`(let ~(subvec bindings 0 2)
(try
(safe ~(subvec bindings 2) ~@code)
(catch Throwable except# except#)
(finally
(. ~(bindings 0) close))))))) ;;safe
(def divider(safe (/ 1 0)))
(def reader (safe [s (FileReader. (java.io.File. "C:/text.txt"))] (. s read)))
So the error Im getting is
=> (def v (safe [s (FileReader. (java.io.File. "C:/text.txt"))] (. s read)))
#'myProject.core/v
=> v
#<ClassCastException java.lang.ClassCastException: java.lang.Integer cannot be cast to clojure.lang.IFn>
So kindly anyone that knows clojure please give me some hints on what is wrong, all the hints Im getting is that there should be a paranthesis missplaced, I've checked the code over and over but cant find any misstypes etc. Thank you !