Re: The D Programming Language
Al skrev:
Hi,
James Kanze wrote:
<snip>
One of Java's faults is that it doesn't allow you to do anything
reasonable (like crashing) when you've detected the problem.
All you can do is log the error and throw an exception, hoping
that 1) nobody silently swallows the exception (except that
major standard library components do silently swallow
exceptions), and 2) someone reads the log, and notices what went
wrong.
That's an interesting problem that honestly I hadn't considered. I guess
it is kind of creepy to know that whoever is calling you might basically
ignore whatever errors you pop up.
On the other hand, from the other point of view (the caller) that's
exactly what is required. It's the very basis of exception safety.
No. Exception safety is entirely unrelated to exception signatures (or
whatever they're called). A process that is concerned about what is
thrown at you is fragile and bound to have a bad fate at one time or
another.
Look instead at C++'s throw(). Seems completely bogus to me. Why?
Because in truth, it guarantees absolutely nothing, unlike Java.
Wrong again. C++ throw() guarantees that the function will not throw
anything, An empty Java throw specification on the contrary guarantees
nothing of that kind.
Moreover, I'm not terribly familiar with the Java APIs, but from a quick
search, this showed up:
http://java.sun.com/j2se/1.4.2/docs/api/java/lang/System.html
Of note is:
static public void System.exit(int);
Which seems to do exactly what you want (i.e., elevate the error all the
way up the hierarchy to make sure it gets paid attention). What more do
you want?
What is wanted is to stop the program without doing anything. In
particular, destructors should not be run.
The best would be to have a core dump, of course so that you can
examine what happened in detail in your nice cosy office chair.
/Peter
[snip]
--
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]