Re: The D Programming Language
"Andrei Alexandrescu (See Website For Email)"
<SeeWebsiteForEmail@erdani.org> writes:
David Abrahams wrote:
Let me try to help. I think you didn't mean to say "preserves its own
guarantees," or at least that's a confusing way to put it. The
*program's* guarantees, as I see it, are the ones made by the author
of the program to himself and to his users, and in the presence of a
programming error, those guarantees are out the window. In a language
without undefined behavior, the guarantees of the underlying system
are still there in spite of programming errors. In other words,
executing "x + 1" still adds 1 to the value of x, and doesn't call a
sorting routine (or whatever).
Great, thanks.
That said, even in a system with no undefined behavior, we have no
idea what the value of x (or anything else in our program) is after a
programming error, so the ability to continue on with the program
executing the instructions you thought you were giving it originally
is not as valuable as it might at first seem.
It's not "anything else in our program". It's "anything else in our
program that was affected by x"
No, not at all. Re-read the scenario; "x" didn't necessarily have
anything to do with the programming error. From a practical point of
view, by the time your internal checks/assertions have detected that
there's been a programming error by inspecting some piece of program
state (call it Z), you have no idea how far the damage has spread.
That is, the program's own guarantees are out the window. That goes
for C++, Java, or any other programming language, and it's why I tell
people that in that situation throwing an exception is almost always
the wrong idea.
and because (say in Java) races only happen on numbers
Meaning that in Java, all writes of "references" (a.k.a. pointers) are
synchronized?
and because there's no pointer forging, that reduces to "any other
number that was affected by x", which considerably reduces the rot
in the program and the difficulty in spotting it. I guess all I can
say is that I tend to see that guarantee as much more valuable. :o)
Than what?
--
Dave Abrahams
Boost Consulting
www.boost-consulting.com
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]