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 22:50:28 PST Path: archiver1.google.com!postnews1.google.com!not-for-mail From: 18k11tm001@sneakemail.com (Russ) Newsgroups: comp.lang.ada Subject: Re: Ideas for Ada 200X Date: 6 Jun 2003 22:50:27 -0700 Organization: http://groups.google.com/ Message-ID: References: <6a90b886.0305262344.1d558079@posting.google.com> <3EDCBDF4.1050900@attbi.com> NNTP-Posting-Host: 63.194.87.148 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Trace: posting.google.com 1054965027 30713 127.0.0.1 (7 Jun 2003 05:50:27 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: 7 Jun 2003 05:50:27 GMT Xref: archiver1.google.com comp.lang.ada:38778 Date: 2003-06-07T05:50:27+00:00 List-Id: Wesley Groleau wrote in message news:... > > 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 you seemed to say that Ada should have > A += B _because_ it is more efficient than A := A + B > > > In C++, I believe it is true that > > A = A + B > > cannot be implemented any more efficiently than > > temp = A > > temp += B > > A = temp > > Ah, now we get to the root of the argument. > C++ allows (or requires?) the two to be implemented > differently. So indeed, it is conceivable that in > C++ one would be more efficient than the other. > > But Ada does not define it at all, and it is highly > unlikely that a new Ada construct defined to have the > same result as another would be _required_ to have a > different implementation. > > And it is unlikely, if it is _allowed_ (but not required) > to have a different implementation, that the vendor (or > programmer, as the case may be) would intentionally > design, code, and test two implementations of the same thing. The two CANNOT be implemented the same! Compare A := B + C + D with A := B A += C A += D (For the sake of argument, let's ignore the Constraint_Error thing for now.) In the latter form, the sums can be done directly in the elements of A. For element i,j, we would have something like A(i,j) += C(i,j), etc. Now consider the first form: A:= B + C + D translates into something like A := Add ( Add(B,C), D ) The first major difference is that "Add" or "+" must RETURN A VALUE, whereas "+=" did NOT need to return a value. The second major difference is that "Add" or "+" needs a temporary storage area (even if we ignore the Constrains_Error thing, which is a separate issue). The temporary is needed to store the value of Add(B,C) because it has no name and no home in memory until a temporary is constructed for it! Then another temporary is needed to store the entire right side, because it has no name or home either. The "+=" form needed no temporaries because everything was done in place in matrices that already had a name and a home in memory. Are you starting to get the picture? "+=" and "+" just cannot be implemented the same. They are two different animals. One returns a value and the other does not. One needs temporary storage and the other does not. Note, however, that "+" CAN be implemented IN TERMS OF "+=", which is what good C++ programmers do. That ensures consistency and eliminates a redundant implementation algorithm. My apologies to the Ada compiler experts who already know this stuff.