[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: OT: Type safety (was: Language War (Re: "C" Manual))



Preben Randhol wrote:

> Well if you write "a + b * c" then you must intend to do just that.

No, my INTENT may have been different; maybe I made a typo. And this is
a trivial example, after all; many logic errors are far more complex and
subtle. To say that all logic errors are intentional would be absurd,
yet that appears to be what you are saying.

> It is common knowledge that a computer will do what you tell it to do not
> what you was thinking of.

Yes, and dereferencing a null pointer is just as much a matter of the
computer doing what you told it to do, not what you really INTENDED it
to do, as an incorrect calculation. Both are cases of the program doing
something you did not want it to do, but which you, in essence, told it
to do, by making an error in the writing of your code.

To say that any compiler, for any language, can guarantee that your
program will do that you INTEND it to do is nonsense.

> I didn't mean to say that it removes logical errors you may make in
> your programming.

The problem is that you implied exactly that.

> But it will remove most errors
> that you do with pointers and automatic typecasting that other languages
> has.

That's a much more precise and accurate statement than what you originally
wrote. Although the compiler doesn't, of course, remove these errors; it
simply refuses to accept the code until you fix them.

Craig



Reply to: