home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.ada
- Path: sparky!uunet!cis.ohio-state.edu!zaphod.mps.ohio-state.edu!sdd.hp.com!spool.mu.edu!yale.edu!qt.cs.utexas.edu!cs.utexas.edu!hellgate.utah.edu!lanl!cochiti.lanl.gov!jlg
- From: jlg@cochiti.lanl.gov (J. Giles)
- Subject: Re: FORTRAN bug(was Re: C++ vs. Ada -- Is Ada loosing?)
- Message-ID: <1992Dec14.183326.27689@newshost.lanl.gov>
- Sender: news@newshost.lanl.gov
- Organization: Los Alamos National Laboratory
- References: <EACHUS.92Dec7184734@oddjob.mitre.org> <1992Dec8.072300.21473@smds.com> <1992Dec8.172551.16780@newshost.lanl.gov> <1992Dec9.060218.23940@seas.gwu.edu> <1992Dec11.132942.24054@mksol.dseg.ti.com> <1992Dec11.163811@lglsun.epfl.ch>
- Date: Mon, 14 Dec 1992 18:33:26 GMT
- Lines: 50
-
- In article <1992Dec11.163811@lglsun.epfl.ch>, nebbe@lglsun.epfl.ch (Robb Nebbe) writes:
- |> Michael Feldman:
- |>
- |> int x;
- |> ...
- |> x = 1;
- |> while (x <= 10);
- |> {
- |> printf("%d\n", x);
- |> x++;
- |> }
-
- One of the first things I do when a C program misbehaves is to check
- the trivial pitfalls. One of the things I look for is "compound
- statements" that aren't the direct object for some control-flow
- construct. If I used C more frequently, I would be tempted to
- write a preprocessor which flagged such things. In this case,
- such a preprocessor would issue a warning that the `{' and `}'
- were redundant.
-
- Without explicitly looking for the above type of error, or having
- an automated tool which looks for it on your behalf, this could be
- a difficult to find error. The problem is that programmers look
- at code and *know* what it's supposed to do. They tend to skim
- the code looking for glaring errors. They miss this sort of thing
- because it's next to invisible. In a large code in which the location
- of the problem is not easy to determine (like maybe this is in one
- of 500 routines which *could* be causing the problem), this could
- take some time to isolate.
-
- Now, I think that the "compound statement" is a poor language design
- feature. This is one of the reasons I think so. Therefore, it's one
- of the features I'm most suspicious of when code goes wrong. I would
- prefer that C would have the following style syntax:
-
- int x
- ...
- x = 1
- while (x <= 10)
- printf("%d\n", x)
- x++
- endwhile
-
- Now there's no way to mix-up where the `while' loop terminates.
- The code is much easier to read and will have significantly
- fewer errors of the "I know what this means, but it's not doing
- it" variety.
-
- --
- J. Giles
-