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 15:01:35 PST Path: pad-thai.cam.ov.com!noc.near.net!chpc.chpc.org!bigboote.WPI.EDU!news.mathworks.com!udel!gatech!newsfeed.pitt.edu!uunet!fdn.fr!univ-lyon1.fr!pasteur.fr!jussieu.fr!uvsq.fr!hebert From: hebert@prism.uvsq.fr (Renaud HEBERT) Newsgroups: comp.lang.ada Subject: Re: "Subtract C, add Ada" Date: 20 Jan 1995 13:22:17 GMT Organization: Laboratoire PRiSM - Universite de Versailles-St Quentin - France Distribution: world Message-ID: <3fode9$dap@soleil.uvsq.fr> References: <3fo2ot$su2@miranda.gmrc.gecm.com> NNTP-Posting-Host: signac.prism.uvsq.fr Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit Date: 1995-01-20T13:22:17+00:00 List-Id: In article <3fo2ot$su2@miranda.gmrc.gecm.com>, bill@valiant (R.A.L Williams) writes: |> |> 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?) Even if I like C, I think that this ++ is ugly and I'm glad that there isn't such a thing in Ada. On the other hand what do you think about the operators += *= ... They make thing shorter AND easier to read, a += 5; means exactly add 5 to a. So don't you think that these construct have their place in Ada. |> |> : -- |> : 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 |> -- Renaud HEBERT e-mail: Renaud.Hebert@prism.uvsq.fr