From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-0.8 required=5.0 tests=BAYES_00,INVALID_DATE autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,1d321b3a6b8bcab2 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 1995-01-12 17:51:42 PST Path: nntp.gmd.de!Germany.EU.net!howland.reston.ans.net!darwin.sura.net!gwu.edu!seas.gwu.edu!dobrien From: dobrien@seas.gwu.edu (David O'Brien) Newsgroups: comp.lang.ada Subject: Re: "Subtract C, add Ada" Date: 13 Jan 1995 01:51:42 GMT Organization: George Washington University Message-ID: <3f4mbe$rud@cronkite.seas.gwu.edu> References: <3etund$hnr@miranda.gmrc.gecm.com> NNTP-Posting-Host: 128.164.9.3 X-Newsreader: TIN [version 1.2 PL2] Date: 1995-01-13T01:51:42+00:00 List-Id: R.A.L Williams (bill@valiant) wrote: : My experience of writing software and running software projects in C : highlights four common low-level C errors: : 1. = instead of == and vice versa I have to wonder. What if C defined the logical equals operator to be "=" and the assignment operator to be ":=" just like Ada, Algol, Pascal, Modula-x, etc? Would this error still exist??? Quickly thinking about it, I feel that I write a lot more assignment statements than local statements, couldn't I be in the habit of typing ":=" and thus accidently type that when I meant logical comparison? Since that would still be a perfectly valid, conforming C program, the compiler is not required to give any warnings (just like current practice). Thus, I would still have the same logic error in my program. Chances of happening??? Any bodies guess. So is the problem really one of symbol choice, or program semantics? : 2. spurious ; after for(...) or while(...) This is one area I *really* like about Ada. However, I feel there is a much more common programming error (occurs in Pascal too): for (...) first_action(); second_action(); The indenting implies that "second_action()" should be part of the the loop body. But it isn't. :-)) So many times I've seen this in industry. Every new programmer I work with I try to drill into their head's "*always* use braces with your if, while, for statements, even when you have only one thing in your loop body. For one day a maintainer will need to add that second thing, and indent like the above -- forgetting to add the braces." Many will not listen thinking they know better. Tisk, tisk, tisk. Usually it doesn't take long for them to get bitten and remember. Same for Pascal. I really don't understand why most languages are designed the Pascal/C way rather than the Ada way. Especially since it removes the common ambiguity of nested if statements. -- David O'Brien (dobrien@seas.gwu.edu)