I have quite a bit of Java code with I/O capabilities that generally
support both PrintStream and PrintWriter. I was a bit perplexed when I
tried to apply one of these methods to *out* and was rebuffed thusly:
java.lang.IllegalArgumentException:
No matching method found: printMessage for class rrs.util.ErrorRecord
As Rich then pointed out to me on #clojure, the problem is that the
concrete type of *out* is:
user=> (class *out*)
java.io.OutputStreamWriter
This leaves almost all of my system's I/O primitives high and dry.
What might be the issues or consequences of making the root binding of
*out* a PrintWriter?
Randall Schulz
I've been using a PrintWriter for *out* for months now, and no problems
so far.
Using always nearly latest svn clojure.
Albert
--
Albert Cardona
http://albert.rierol.net
You're _changing_ *out* to a PrintWriter. I'm talking about making the
root binding of *out* a PrintWriter wrapped around System.out.
> Albert
Randall Schulz
Perhaps a bit odd is this:
user=> (class *err*)
java.io.PrintWriter
Randall Schulz
(pretty clever way to do a bump, eh?)
user=> (class *err*)
java.io.PrintWriter
Well, if *out* continues to be a vanilla (non-Print-) Writer, then it
will have to be, I suppose.
I consider it pretty fragile to work with an altered root binding for
*out*, so I doubt I'll go that route. On the other hand, having
multiple paths that ultimately converge on System/out leads to the
potential for out-of-order appearance of data directed through those
disparate paths when they are liberal in their flushing policy (which
in this context means they do rather little of it).
So from my perspective there's no ideal solution under the current
circumstances. I really don't know why *out* (its initial root binding)
should _not_ be a PrintWriter, especially when it is ultimately
directed at System/out, which is itself a PrintStream.
And why is *err* a PrintWriter when *out* is not?
Consider, too, that PrintWriter has format(...) / printf(...) methods
not available on any non-Print Writer class.
> --Steve
Randall Schulz