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-20 02:20:13 PST Path: nntp.gmd.de!newsserver.jvnc.net!nntpserver.pppl.gov!princeton!gw1.att.com!fnnews.fnal.gov!uwm.edu!vixen.cso.uiuc.edu!howland.reston.ans.net!news.sprintlink.net!pipex!uknet!hrc63!gmrc.gecm.com!valiant!bill From: bill@valiant (R.A.L Williams) Newsgroups: comp.lang.ada Subject: "Subtract C, add Ada" Date: 20 Jan 1995 10:20:13 GMT Organization: GEC-Marconi Research Centre Message-ID: <3fo2ot$su2@miranda.gmrc.gecm.com> NNTP-Posting-Host: valiant.gmrc.gecm.com X-Newsreader: TIN [version 1.2 PL1] Date: 1995-01-20T10:20:13+00:00 List-Id: In article <3f5s92$3id@info.epfl.ch> you wrote: : In article <3f4mbe$rud@cronkite.seas.gwu.edu>, dobrien@seas.gwu.edu (David O'Brien) writes: : |> 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??? : The problem is in the language definition, not in the choic of symbols. : C is one of the rare language I use to allow having an assignment after : the if statement. All other languages only allow for a boolean test. : I never saw a good reason for allowing this. I think there are three reasons: 1. It allows your code to be more compact. Many people think this is a disadvantage, and so it is if the code will be read by comparative novices, but it can improve readability to C experts who are expecting such tricks. NB DONT confuse compactness with poor layout! I find that, for example: while ((c = getchar()) == ' ') { /* count spaces */ } is clearer than the 'expanded' alternative (to *me* :-). 2. All expressions in C have a value. Conditional tests succeed on non-zero and fail on zero. Therefore, to maintain orthogonality, as far as possible, there is no reason to exclude an assignment expression from a condition. 3. Finally, I suspect, this can simplify the optimisation algorithms in the compiler. Personally, the lack of this sort of compactness in Ada, and things like pre- and post-increment/decrement are one of my minor gripes about the language. OK, its no big thing to write: P(I) := Q(I); I := I + 1; instead of *p++ = *q++; but I actually *do* find the C representation easier/better etc. (perhaps I'm wierd?) : -- : Laurent Gasser (gasser@dma.epfl.ch) : Computers do not solve problems, they execute solutions. : I know very few ideas worth dying for, none is worth killing. Very true, but quite a few are worth a pint in the pub. Bill Williams