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,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,38fc011071df5a27 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-06-06 11:10:09 PST Path: archiver1.google.com!postnews1.google.com!not-for-mail From: 18k11tm001@sneakemail.com (Russ) Newsgroups: comp.lang.ada Subject: Ideas for Ada 200X Date: 6 Jun 2003 11:10:08 -0700 Organization: http://groups.google.com/ Message-ID: References: <6a90b886.0305262344.1d558079@posting.google.com> <3EDCBDF4.1050900@attbi.com> NNTP-Posting-Host: 128.102.146.44 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Trace: posting.google.com 1054923009 32433 127.0.0.1 (6 Jun 2003 18:10:09 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: 6 Jun 2003 18:10:09 GMT Xref: archiver1.google.com comp.lang.ada:38765 Date: 2003-06-06T18:10:09+00:00 List-Id: Wesley Groleau wrote in message news:... > Russ wrote: > > I think you're missing something here. I would write "+=" too. > > If the _coder_ is going to define Add() and "+" and "+=" > then clearly it is misleading to claim that "+=" is > always more efficient. First of all, I don't know where the idea came from that "+" or "+=" would NOT be written by the programmer (for user-defined types). I never suggested any such thing, nor has anyone else on this thread as far as I recall. Nor did I ever claim that "+=" is "always more efficient." Of course that would be nonsense -- I could put an infinite loop in the freakin' thing if I wanted to! > But if a language standard requires A += B > to always be equivalent to A := A + B > then clearly it is misleading to > insist that either one will always > be more efficient. Perhaps I erred in my earlier posts in assuming that certain principles that apply to C++ also apply to Ada, so let me restate my claim. In C++, I believe it is true that A = A + B cannot be implemented any more efficiently than temp = A temp += B A = temp Thus A = A + B could not possibly be as efficient as A += B because the former requires the construction and destruction of a temporary as well as an extra copy operation. So although the result is identical (if properly implemented), the efficiency is certainly not. The point is that "+=" gets you directly into the left-hand side without having to "cross the bridge" of an "=". That much is not controversial, folks. Most good C++ programmers know it. For a good discussion, see More Effective C++ (1996) by Scott Meyers, Item 22: Consider using op= instead of stand-alone op. Now I had assumed, perhaps erroneously, that the same principle applies to Ada. *If* it does not, I believe it could only be because, for whatever reason, "+=" cannot be implemented as efficiently in Ada as it can in C++. And please, hold your fire on C++. I agree completely that Ada beats C++ hands down for safety, readability, maintainability, etc. However, I think you are deluding yourself if you think Ada is more efficient than C or C++.