On Monday, December 8, 2014 7:32:29 PM UTC-5, Stuart Sierra wrote:
>
> As the original author of the function that eventually became 
> clojure.java.io/reader, it was one of those unfortunate decisions that 
> seemed like a good idea at the time and cannot be changed without breaking 
> backwards compatibility.
>
> Long before EDN existed, I wrote clojure.contrib.io 
> https://github.com/clojure/clojure-contrib/blob/1.2.x/src/main/clojure/clojure/contrib/io.clj
>
> This included a function `reader` that returned a java.io.BufferedReader: 
> http://docs.oracle.com/javase/7/docs/api/java/io/BufferedReader.html
>
> BufferedReader was a convenient type to return because it supports 
> .readLine, which is used by clojure.core/line-seq: 
> https://github.com/clojure/clojure/blob/1.1.x/src/clj/clojure/core.clj#L1954-L1960
>
> However, clojure.core/read and later clojure.edn/read were written in 
> terms of java.io.PushbackReader, because they need the ability to look 
> ahead one character in the stream while parsing it:
> http://docs.oracle.com/javase/7/docs/api/java/io/PushbackReader.html
>

Seems like the simplest fix at the library level would be to make core/read 
and edn/read accept both classes and wrap BufferedReaders in 
PushbackReaders themselves, then.
 

> It turns out there are some subtle issues which can cause incorrect 
> behavior were clojure.core/read to blindly wrap a PushbackReader around its 
> argument:
> https://groups.google.com/d/msg/clojure/_tuypjr2M_A/W1EcEbMUg_cJ
>

That sounds like magic. The user wrapping a PushbackReader around a 
BufferedReader doesn't cause problems, but the library function doing so 
does? Why would where the wrapping takes place make a difference? Is the 
*only* problem the rare case of reading more than one object from the same 
stream? A docstring warning to wrap manually *in those cases* would 
suffice, then, no?

-- 
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.

Reply via email to