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.9 required=5.0 tests=BAYES_00,FORGED_GMAIL_RCVD, FREEMAIL_FROM autolearn=no 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!postnews.google.com!z14g2000cwz.googlegroups.com!not-for-mail From: "Hans Malherbe" Newsgroups: comp.lang.ada,comp.lang.c++,comp.realtime,comp.software-eng Subject: Re: Teaching new tricks to an old dog (C++ -->Ada) Date: 9 Mar 2005 06:07:40 -0800 Organization: http://groups.google.com Message-ID: <1110377260.350158.58730@z14g2000cwz.googlegroups.com> 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> <1110052142.832650@athnrd02> <1110284070.410136.205090@o13g2000cwo.googlegroups.com> <395uqaF5rhu2mU1@individual.net> NNTP-Posting-Host: 196.8.104.31 Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" X-Trace: posting.google.com 1110377264 22739 127.0.0.1 (9 Mar 2005 14:07:44 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Wed, 9 Mar 2005 14:07:44 +0000 (UTC) In-Reply-To: <395uqaF5rhu2mU1@individual.net> User-Agent: G2/0.2 Complaints-To: groups-abuse@google.com Injection-Info: z14g2000cwz.googlegroups.com; posting-host=196.8.104.31; posting-account=vaFgcA0AAADo7zN227lGnIpnwjwpYkPg Xref: g2news1.google.com comp.lang.ada:8929 comp.lang.c++:44763 comp.realtime:1121 comp.software-eng:4680 Date: 2005-03-09T06:07:40-08:00 List-Id: >> Reading this thread, it seems to me Ada's focus is on safety rather >> than efficiency. >> These safety constraints also tend to limit expressiveness. Not that >> safety is bad, just that it's not free. >Actually, a close reading of the thread should have made it clear that >the additional safety is indeed "free". Since the majority of Ada's >checks are compile time they do not impact on run-time efficiency. >. >. >. >Can you say what led you to the opposite conclusion? I wouldn't call it a conclusion, but here goes... Somewhere in this thread Loduvic writes: * in Ada, loop variables (a) are constants and (b) do not exist outside of the loop This is safer, but limiting. In C++ may want to declare the variable outside the loop, break out early and use the loop variable. Let me guess: You can't break out early in Ada, right? * assignment is not an operator; it is an operation which does not return a value. Thus, bugs like "if (something = 0)" cannot exist. I like this, but it prevents chaining assignments, limiting expressiveness slightly since chaining says "equalize" as opposed to "assign, assign, assign". * case statements (Ada's equivalent of a switch in C++) are required to handle all possible cases. Thus it is impossible to forget one. And, of course, there is no "break;" crap in Ada. Prevents fall through. * 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. This is more in the C++ tradition. The programmer has choice. In C++ you can extend the type system to achieve this and more (someone mentioned dimensional analysis), just not with typedef. * accessibility rules are rather complex, but they are designed to minimise the chance of mistakes. Basically, the scope of a pointer type must be included in the scope of the pointed-to type. This makes many mistakes impossible, such as returning a pointer to an object which no longer exists. This looks like a limitation, but I'm not sure I understand correctly. Example please! A few other questions: Do you have nested functions like Pascal have? Can you access local variables? Can you pass pointers to these functions around? Can you pass non-type parameters (like the number 3.14) to templates? Can templates recurse? Can you program "const correct"? Eg. if you declare a member function as const the compiler will help you not mutate the object or call any functions that do. Also, if you pass a parameter as a const reference, you will not be able to mutate the object the parameter references.