I'm trying to write a macro for use from ClojureScript to handle file I/O for a Reagent app. I get this error:
IllegalArgumentException: No implementation of method: :as-file of protocol: #'clojure.java.io/Coercions found for class: clojure.lang.Symbol
When I try to do the following:
(def file-string "/Users/luciano/Dropbox/projects/test/resources/blog/test.md")
(get-file file-string)
But I can do this just fine:
(get-file "/Users/luciano/Dropbox/projects/test/resources/blog/test.md")
This is the macro:
(defmacro get-file [fname]
(slurp (io/file fname)))
What am I doing wrong here?
What this means is you are trying to call the macro with a symbol that doesn't have a value at runtime.
(def my-file "foo.txt")
(def file-str (get-file my-file))
Will work while
(defn foo [s]
(get-file s))
(foo "foo.txt")
will not.