Re: strange typecheck error

2010-01-02 Thread Alex Ott
Many thanks to you Bill - it works! .Bill Smith at "Fri, 1 Jan 2010 10:44:37 -0800 (PST)" wrote: .S> Happy New Year to you, Alex. .S> I reproduced the problem as follows: .S> user=> (loop [x (byte 0) count 0] .S> (if (< count 10) (recur 0 (inc count .S> java.lang.RuntimeException: ja

Re: strange typecheck error

2010-01-01 Thread .Bill Smith
Happy New Year to you, Alex. I reproduced the problem as follows: user=> (loop [x (byte 0) count 0] (if (< count 10) (recur 0 (inc count java.lang.RuntimeException: java.lang.IllegalArgumentException: recur arg for primitive local: x must be matching primitive (NO_SOURCE_FILE: 57) user=> I

Re: strange typecheck error

2009-12-31 Thread Alex Ott
Hello Bill .Bill Smith at "Thu, 31 Dec 2009 09:20:16 -0800 (PST)" wrote: .S> I tried out your example with a couple of files and it appeared to .S> work. Is it supposed to fail, or is this an example of what you had .S> to do to work around the problem you mentioned? Yes, this is working var

Re: strange typecheck error

2009-12-31 Thread .Bill Smith
I tried out your example with a couple of files and it appeared to work. Is it supposed to fail, or is this an example of what you had to do to work around the problem you mentioned? It's certainly ok for a function to return different data types. I guess the simplest example of that would be th

Re: strange typecheck error

2009-12-31 Thread Alex Ott
Hello I'm sorry, i tried to prepare shorter example, and mixed loops & recurs. Full example is attached. This is code, that implements something like 'strings' command on Unixes, but for UTF-8 encoding The problem is, that i need to return from function 'read-utf-char', either String, either Int

Re: strange typecheck error

2009-12-31 Thread Alex Ott
Nikolay Petrov at "Wed, 30 Dec 2009 18:13:13 +" wrote: NP> Is process char returns char or String? I want to return either String, either Integer, depending on condition... -- With best wishes, Alex Ott, MBA http://alexott.blogspot.com/http://xtalk.msk.su/~ott/ http://alexott-ru.

Re: strange typecheck error

2009-12-30 Thread rzeze...@gmail.com
On Dec 30, 12:53 pm, Alex Ott wrote: > > If need, i can submit somebody full test case I think this might help because it's hard to tell what you are trying to do without a little more context. Some odd things that stand out to me: 1) You call loop, but you should be calling recur. E.g. (lo

Re: strange typecheck error

2009-12-30 Thread .Bill Smith
Sorry, I'm confused by the code sample. I see several loops but no corresponding recurs. On Dec 30, 11:53 am, Alex Ott wrote: > Hello all > > I have strange problem with type inference in Clojure.  I have following > code (simplified version of real code), > > (defn- process-char [#^InputStream

Re: strange typecheck error

2009-12-30 Thread Nikolay Petrov
Is process char returns char or String? --Original Message-- From: Alex Ott Sender: clojure@googlegroups.com To: Clojure ML ReplyTo: clojure@googlegroups.com Subject: strange typecheck error Sent: Dec 30, 2009 19:53 Hello all I have strange problem with type inference in Clojure. I have

strange typecheck error

2009-12-30 Thread Alex Ott
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 [