Structs (was RE: Record selectors)
Shawn Pearce
spearce@REDACTED
Thu Jan 16 16:58:10 CET 2003
Miguel Barreiro Paz <enano@REDACTED> wrote:
> I suppose exception throwing mechanisms were invented among other
> reasons to simplify the horrible code that results from defensive
> programming; ie., after a few burnouts C programmers turn every function
> call and assignment line into ten lines or so (check whether results are
> valid, then do something sensible if they aren't, continue otherwise).
> Now, languages like Java do have exception throwing mechanisms, but many
> programmers insist on C-style manual result checking.
>
> Some people around does suffer from Java daily :)
Not that exception throwing helps any:
InputStream file = null;
try
{
file = new FileInputStream(...);
read from file
file.close();
} catch (IOException ioe)
{
if (file != null)
{
try
{
file.close();
} catch (IOException ioe2)
{
// What do i do if i can't close the
// file during an error? Assume it's
// ok to ignore the second error?
}
}
throw ioe;
}
is just an annoying mess in Java. Exceptions are not always
what their designers thought they would be. I'm sure someone
here could come up with a better format for that mess though.
Personally, I prefer Erlang, but am told to write Java, as its
GOL. *sigh*
--
Shawn.
More information about the erlang-questions
mailing list