Hello all
I have strange problem with type inference in Clojure. I have following
code (simplified version of real code),
(defn- process-char [#^InputStream istream]
(let [ch (.read istream)]
(if (= ch 10)
"AAA"
ch)))
(defn- process-text [#^InputStream istream]
(loop [char (.read istream)]
(let [result (process-char istream)]
(cond
;; .. some additional conditions
(string? result) (loop (.read istream))
(number? result) (loop result)
...))))
Main idea, that in some function, i read characters in sequence, and check
their values, and in some conditions, i need to re-submit already readed
character into loop, but when i use code above, i get following error:
java.lang.IllegalArgumentException: recur arg for primitive local: char must be
matching primitive
[Thrown class java.lang.RuntimeException]
but if i replace (loop result) with (.read istream), then it works without
any problems
I checked type of result, and it's Integer - same type, that 'char' var in
loop will get after reading from stream.
If need, i can submit somebody full test case
--
With best wishes, Alex Ott, MBA
http://alexott.blogspot.com/ http://xtalk.msk.su/~ott/
http://alexott-ru.blogspot.com/
--
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