Hi,
> I don't do a lot of writing of text to local disk, so I actually
> hadn't noticed.
> I presume the usage of PrintWriters is to maximize utility when
> rebinding *out* and *err*. But yes, I'd worry about using
> PrintWriters for general-purpose use.
I think that it is a bit of a problem.
Clojure doesn't have any 'fprintf'-like functions, which would allow
you to print to specific streams. My understanding is that rebinding
*out* to a different java.io.Writer, and using print is the
recommended way of printing text to arbitrary streams. The presence of
the print-method multi-methods, and print-dup, I think confirms that.
Those aren't things that you want to cook up with yourself with
(.println out whatever), and they aren't very useful as they are bound
to stdout.
Given the expectation to use print for things other than the console,
and the opinion that PrintWriter isn't a suitable wrapper for writing
to files and sockets, due to it dropping exceptions on the floor, I
think it is wrong for anyone to assume that *out* is a PrintWriter.
And the documentation clearly says that it is a Writer.
I understand that there is code that assumes that *out* is a
PrintWriter, even though it is documented to be a Writer. I think that
that code needs to change.
> Of course,
c.c.io/writer (and
> duck-streams/writer) has been returning PrintWriters for a long time
> without things burning down. The question is, is this a problem
> waiting to happen, or are we just paranoid? ;-)
I do my file writing from Java, and don't use contrib at all, so I
haven't hit problems from Clojure either. But I would never use
PrintWriters for anything other than trivial console output when I'm
programming in Java.
Is duckstreams is moving to
clojure.contrib.io for the release
transition from 1.1 to 1.2?
If so, now would be a great time to change to
clojure.contrib.io to
returning BufferedWriters.
--
Dave
--
You received this message because you are subscribed to the Google Groups "Clojure Dev" group.
To post to this group, send email to
cloju...@googlegroups.com.