J
James Kuyper
CBFalconer said:Keith Thompson wrote: ....
Always bear in mind that this discussion is for and on c.l.c. As I
read your suggestions, you seem to believe that any programmer,
when handed some code to modify/use/etc., should read it in its
entirety, identify anything not guaranteed by the C standard, and
verify its action on the system in question.
He neither said nor even implied anything of the kind.
No, it's not always necessary to read and understand an entire program
in order to make a small change. Well-designed code allows sufficiently
minor maintenance work to be performed without having to read and
understand the entire program, just the part being modified. Of course,
if this happens too often, it ceases to be well-designed code.
No, it's not always necessary to verify its action on the system in
question. It should be possible to determine what the requirements are
for the degree of portability the code should achieve. Those
requirements might, for example, state that it need only work on one
specific machine; they might say that they have to work on any platform
supporting a particular OS, or they might say it must work on any
conforming implementation of C90. Ideally, there's a requirements
document that specifies this. The programmer need only confirm that the
code meets whatever the requirements are (and bring it to the attention
of the person responsible for the requirements if they seem unreasonable).
For example, if a particular piece of code is, as a matter of deliberate
design, intended only for use on Windows, there's nothing wrong with it
containing features that are not guaranteed to work by the C standard,
as long as they are guaranteed to work by the relevant Windows authority
(whatever that might be).
Such Windows-specific software is off-topic in this newsgroup, but just
because it only works on Windows platforms does not justify lying about
what's wrong with mentioning it, by claiming that it does not work.
... I maintain this is
ridiculous, not to mention time consuming. If code is not
guaranteed to work I maintain that assuming it will not work is the
safe technique, and reorganizing it so it will always work (if
possible) prevents any future problems. The first step in this
process is recognizing that the code is not guaranteed.
Just because the C standard doesn't guarantee that the code will work
does not mean that the code is not guaranteed to work. Almost any
real-world program relies on some combination of the C standard and some
other authorities to guarantee that it will work, and for that reason,
it is guaranteed to work only in the joint domain where all of the
relevant authorities are authoritative. Claiming that such code "won't
work" is just plain false; it will work in that domain, and might or
might not work outside of it. A flat statement of "won't work" is
incompatible with that fact.