On Jun 21, 2009, at 11:17 PM, arasoft wrote:
When I enter the following function into the REPL it compiles and
works without problems:
(defn harmonic-number [n prec]
(reduce + (map #(with-precision prec (/ 1 (bigdec %))) (range 1 (inc
n))))
)
After (set! *warn-on-reflection* true), in a normal REPL I get:
Reflection warning, NO_SOURCE_PATH:3 - call to java.math.MathContext
ctor can't be resolved.
You can give the compiler a type hint on prec to avoid the reflection:
(defn harmonic-number [n #^Integer prec]
(reduce + (map #(with-precision prec (/ 1 (bigdec %))) (range 1 (inc
n))))
)
In Enclojure, it's worse: <CompilerException java.lang.ClassCastException: java.io.OutputStreamWriter cannot be cast to java.io.PrintWriter (NO_SOURCE_FILE:8)>
(At least) some versions of Enclojure are binding *err* to an OutputStreamWriter rather than a PrintWriter. Clojure's default binding is to a PrintWriter and some of Clojure expects a PrintWriter.
I consider binding *err* to an OutputStreamWriter to be a bug. I think the Enclojure developers know about it, so if there's a version of Enclojure you haven't upgraded to, I recommend trying that.
If you're using the latest version, I suggest taking a look at their bug list (if it's public) and/or letting them know about it.
--Steve
smime.p7s
Description: S/MIME cryptographic signature
