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=-1.9 required=5.0 tests=BAYES_00 autolearn=ham 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-31 01:34:10 PST Path: nntp.gmd.de!newsserver.jvnc.net!news.cac.psu.edu!news.pop.psu.edu!psuvax1!uwm.edu!cs.utexas.edu!swrinde!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: 31 Jan 1995 09:34:10 GMT Organization: GEC-Marconi Research Centre Message-ID: <3gl06i$s03@miranda.gmrc.gecm.com> NNTP-Posting-Host: valiant.gmrc.gecm.com X-Newsreader: TIN [version 1.2 PL1] Date: 1995-01-31T09:34:10+00:00 List-Id: In article <1995Jan23.154631.6702@sei.cmu.edu> you wrote: : In article <3fo2ot$su2@miranda.gmrc.gecm.com> bill@valiant (R.A.L Williams) writes: : I guess I'm about to show my ignorance of C, but I'm very confused : bt this post. : > 1. It allows your code to be more compact. : > 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* :-). : Nope, I find this totally unclear. Who's counting? Unless I've missed : an invisible declaration, initialisation, and increment, the above : code *doesn't* count spaces, it skips them. And if that is its : purpose, what's the point of the variable 'c'? Why not just say OK, I'm sorry, I didn't think I needed to spell things out in gratuitous detail, so I just indicated the position and sort of code that might be used by a comment. I haven't shown code that replaces spaces in an output stream with text from the Koran either, sorry! : Note also that if there are *no more* non space characters, the C code : dies in an infinite loop, while the Ada code automatically does the : right thing, namely raises the END_ERROR exception. I'm afraid you *are* showing your ignorance of C. On each iteration of the loop if the next input character is not a space (and this includes EOF) then the loop terminates cleanly. : >[example deleted] : Again, I don't see it. The Ada code makes it clear that *corresponding* : elements of the array Q are being copied into P - though, of course, : a real Ada programmer (TM) would have written just P := Q. The C code : doesn't make that clear - you're going to have to ferret out the : initialisations of p and q to determine that. And if you worry about : the correctness of the copy - for instance, whether P and Q are the : same size - that's surely going to be a lot easier to establish in Ada. Again, a simplified example to illustrate a principle. The point is that the less I have to move my eyes, or flip over pages, when reading/reviewing code, the more likely I am to understand it and find any bugs. You're quite right, P := Q is an event more compact representation and I approve (the Bill Williams official statement of approval!). Bill Williams