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-Thread: 103376,703c4f68db81387d X-Google-Thread: 109fba,703c4f68db81387d X-Google-Thread: 115aec,703c4f68db81387d X-Google-Thread: f43e6,703c4f68db81387d X-Google-Attributes: gid103376,gid109fba,gid115aec,gidf43e6,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news4.google.com!news.glorb.com!wn13feed!worldnet.att.net!12.120.4.37!attcg2!ip.att.net!news.binc.net!kilgallen From: Kilgallen@SpamCop.net (Larry Kilgallen) Newsgroups: comp.lang.ada,comp.lang.c++,comp.realtime,comp.software-eng Subject: Re: [OT] Re: Teaching new tricks to an old dog (C++ -->Ada) Date: 5 Mar 2005 14:12:38 -0600 Organization: LJK Software Message-ID: References: <4229bad9$0$1019$afc38c87@news.optusnet.com.au> <1110032222.447846.167060@g14g2000cwa.googlegroups.com> <871xau9nlh.fsf@insalien.org> <3SjWd.103128$Vf.3969241@news000.worldonline.dk> <87r7iu85lf.fsf@insalien.org> NNTP-Posting-Host: eisner.encompasserve.org X-Trace: grandcanyon.binc.net 1110053454 10741 192.135.80.34 (5 Mar 2005 20:10:54 GMT) X-Complaints-To: abuse@binc.net NNTP-Posting-Date: Sat, 5 Mar 2005 20:10:54 +0000 (UTC) Xref: g2news1.google.com comp.lang.ada:8666 comp.lang.c++:44204 comp.realtime:950 comp.software-eng:4481 Date: 2005-03-05T14:12:38-06:00 List-Id: In article , "Peter Koch Larsen" writes: > > "Ludovic Brenta" skrev i en meddelelse > news:87r7iu85lf.fsf@insalien.org... >> it at hand anyway, but the gist of it is that, in Ada, loop variables >> (a) are constants and (b) do not exist outside of the loop: > This is inherited from Pascal if I remember correctly. Of course, good C++ > style is to declare your variable in the loop. That is also good style in macro assemblers, and presumably in paper-only languages used to write machine code where you toggle in the binary. But the purpose of a compiler is to help you avoid errors, whether you think of such things at the time or not. >> * conditions cannot mix "and" and "or" without parentheses. Thus >> there is no possibility that the programmer make wrong assumptions >> about precedence of operators or order of evaluation. > > This seems ridiculous. I would expect a programmer to know the precedence > rules or at least insert parentheses if they are in doubt. Expectations are one thing, but having the compiler help you is better. >> * the type system, when used appropriately, makes it possible for the >> compiler to find semantic errors in addition to just syntax errors. >> For example, you can declare that Numers_Of_Apples and >> Numers_Of_Oranges cannot be mixed. This is not possible with C++'s >> typedef. > > I like that idea. It is possible using templates, of course. Is it general > enough? If you replace "apples" with "weight" and "oranges" with "length", > is it then permissible to multiply a length with a weight but not add the > two together? It is possible, with enough work, to do such things. It is preferable to mandate that such project-specific needs be programmed only by senior programming staff. Thus the junior members of the staff just say this_box_length * this_box_weight. Any responsibility for the meaningfulness of that result is on the shoulders of senior staff. > My conclusion is that there are some nice ideas out there, but that they > mainly protect against the "sloppy" programmer. My conclusion after 35 years with computers is that there are "sloppy" programmers out there. So I look for mechanisms to guard against such things. Formal inspection is great, but it is a waste of resources if used to catch small errors that can be avoided with proper choice of tools.