Re: Inflection on clojure.java.io/reader and writer

2013-02-06 Thread Valentin Golev
> Welcome to a world of values, not containers (the blue pieces can only fit in the blue > container, the red ones you get the picture) or as Rich says places. I always thought that by places he means mutable identifiers; languages like Haskell have a lot of luck with type-checking immut

Re: Inflection on clojure.java.io/reader and writer

2013-02-05 Thread Softaddicts
You are not defining a type here. A type hint is just that... a hint so the compiler can optimize the code it generates to call the readLine method on this specific object class. As an example, if io/reader returned an object of a different class at runtime than BufferedReader, it would not fail

Re: Inflection on clojure.java.io/reader and writer

2013-02-05 Thread AtKaaZ
*I would love it if it would be* at least a warning if not even better *an error*, but I feel it wouldn't be idiomatic clojure to err, but to warn would maybe be accepted... On Tue, Feb 5, 2013 at 6:34 PM, Kanwei Li wrote: > That's funny, I did exactly the same thing and wrote BufferedReader fo

Re: Inflection on clojure.java.io/reader and writer

2013-02-05 Thread Kanwei Li
That's funny, I did exactly the same thing and wrote BufferedReader for both. DOH! Although I have no idea how the internals of type hinting is, I do think it's peculiar that there doesn't seem to be type error checking, even though we are explicitly "defining" the type. I would feel like it sh

Re: Inflection on clojure.java.io/reader and writer

2013-02-04 Thread AtKaaZ
in other words: this: (let [in (clojure.java.io/reader src) out (clojure.java.io/writer dest) becomes this: (let [^java.io.BufferedReader in (clojure.java.io/reader src) ^java.io.BufferedWriter out (clojure.java.io/writer dest) and it works for me too. (but I wasted some time

Re: Inflection on clojure.java.io/reader and writer

2013-02-04 Thread Andy Fingerhut
I don't have CCW Eclipse installed to test, but by saving that file on my Mac (should also work on Linux) in a subdirectory "obj", and editing it to add the ^java.io.BufferedReader in and ^java.io.BufferedWriter out type hints as suggested by Luc P. earlier in this thread, I was able to eliminat

Re: Inflection on clojure.java.io/reader and writer

2013-02-04 Thread Kanwei Li
Hey Andy, Thanks for offering to help. Here's a gist: https://gist.github.com/4696105 As you can see at the bottom, I want the main method to read/write to STDIN/STDOUT, but for testing, I want to read from files instead. This is what I get in both CCW Eclipse and nrepl: Reflection warning, NO

Re: Inflection on clojure.java.io/reader and writer

2013-02-03 Thread AtKaaZ
works for me: => (*let [^java.io.BufferedReader a (clojure.java.io/reader"c:\\windows\\setupact.log")] (println (. a readLine))) * AudMig: No audio endpoint migration settings found 0x2 nil => *(let [a (clojure.java.io/reader "c:\\windows\\setupact.log")] (println (. a readLine)))* Reflection warn

Re: Inflection on clojure.java.io/reader and writer

2013-02-03 Thread Andy Fingerhut
Can you post a larger chunk of code for us to examine, perhaps on github or as a gist if it is over 30 lines of code or so? Many of us have had good success with eliminating reflection using type hints, so it should be possible to make it work. Andy On Feb 3, 2013, at 12:50 PM, Kanwei Li wrot

Re: Inflection on clojure.java.io/reader and writer

2013-02-03 Thread Kanwei Li
Unfortunately it doesn't work. Reflection warning, NO_SOURCE_PATH:20 - call to write can't be resolved. Reflection warning, NO_SOURCE_PATH:21 - reference to field newLine can't be resolved. On Sunday, February 3, 2013 2:35:23 PM UTC-5, Luc wrote: > > Why not add type hints like this ? > > (let

Re: Inflection on clojure.java.io/reader and writer

2013-02-03 Thread Softaddicts
Why not add type hints like this ? (let [^java.io.BufferedReader in ^java.io.BufferedWriter out ...] .. Luc P. > Hey guys, > > I'm trying to read a lot of data, sometimes from *in* and sometimes from a > file. I extensively use the native .write and .read java methods. > > Accordi

Inflection on clojure.java.io/reader and writer

2013-02-03 Thread Kanwei Li
Hey guys, I'm trying to read a lot of data, sometimes from *in* and sometimes from a file. I extensively use the native .write and .read java methods. According to the clojure doc for reader, it says that "Default implementations always return a BufferedReader". However, when I write, (*defn*