I have the following code (very simple) for writing some binary data
to a file

(def ^{:dynamic true} *out*)

;; writers
(defmulti write-a
  (fn [spec val]
    (cond
      (keyword? spec) spec)))

(defmethod write-a :byte [_ val]
  (.writeByte *out* (int val)))

And this code to write to the dynamic *out* binding

(defn id3-encode
  ([] (id3-encode test-out))
  ([file]
    (with-open [out (-> (File. file) (FileOutputStream.)
(BufferedOutputStream.) (DataOutputStream.))]
      (binding [*out* out]
        (map #(write-a :byte %) [\I \D \3])))))

When i run the id3-encode function I get this exception:

user=> (fixlkg.fix/id3-encode)

(user=> IllegalArgumentException No matching method found: writeByte
for class clojure.lang.Var$Unbound
clojure.lang.Reflector.invokeMatchingMethod (Reflector.java:52)

Could somebody help explain why this is happening. It appears to be
because of either the map or the anonymous function. Because if I
change the function to just iteratively call (write-a :byte \I) (write-
a :byte \D) etc it works fine.

Thanks,
matthew

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Reply via email to