Regardless of the outcome of the type issue, this code is doing blocking io inside a go block, which should be avoided. Consider using `thread` and `loop`, which would also likely work around the type hinting issue because it would avoid the state machine transform. The code already using the blocking version of channel put (>!!) which shouldn't be used inside a go block, but is fine for use outside of it.
On 7/23/15 9:38 AM, Adam Krieg wrote: > Hi all, > > I have an issue with references to closed over references outside the go > block not resolving types. The first function resolves fine. The > second one cannot resolve (.readLine buf-reader) > > (defn parser-process-good > "Consumes lines from a file, transforms entries of interest and puts them > on a channel" > [^String file pred xform out-channel] > (let [buf-reader (BufferedReader. (FileReader. file))] > (async/go-loop [^BufferedReader reader buf-reader] > (when-let [line (.readLine reader)] > (do > (if (pred line) (async/>!! out-channel (xform line))) > (recur reader)) > )) > )) > > (defn parser-process-bad > "Consumes lines from a file, transforms entries of interest and puts them > on a channel" > [^String file pred xform out-channel] > (let [buf-reader ^BufferedReader (BufferedReader. (FileReader. file))] > (async/go-loop [] > (when-let [line (.readLine buf-reader)] ;reference to field or no args > method call readLine cannot be resolved > (do > (if (pred line) (async/>!! out-channel (xform line))) > (recur)) > )) > )) > > > The closed Jira item I found was ASYNC-28, but it was closed as not > reproducible. I'm getting this using 0.1.346.0-17112a-alpha. > > > > > > -- > You received this message because you are subscribed to the Google > Groups "Clojure" group. > To post to this group, send email to clojure@googlegroups.com > Note that posts from new members are moderated - please be patient with > your first post. > To unsubscribe from this group, send email to > clojure+unsubscr...@googlegroups.com > For more options, visit this group at > http://groups.google.com/group/clojure?hl=en > --- > You received this message because you are subscribed to the Google > Groups "Clojure" group. > To unsubscribe from this group and stop receiving emails from it, send > an email to clojure+unsubscr...@googlegroups.com > <mailto:clojure+unsubscr...@googlegroups.com>. > For more options, visit https://groups.google.com/d/optout. -- And what is good, Phaedrus, And what is not good— Need we ask anyone to tell us these things? -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.