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-02 22:27: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: 2 Jun 2003 22:27:27 -0700 Organization: http://groups.google.com/ Message-ID: References: <6a90b886.0305262344.1d558079@posting.google.com> <3ED41344.7090105@spam.com> <3ED46D81.FF62C34F@0.0> <3ED46E07.4340CABC@0.0> <3ED4F3FD.A0EF7079@alfred-hilscher.de> <6vWcnTWjF83bD0qjXTWcpA@gbronline.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 1054618048 21284 127.0.0.1 (3 Jun 2003 05:27:28 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: 3 Jun 2003 05:27:28 GMT Xref: archiver1.google.com comp.lang.ada:38434 Date: 2003-06-03T05:27:28+00:00 List-Id: Wesley Groleau wrote in message news:... > > No, they aren't the same. The result is the same, but the second form > > can be implemented much more efficiently. The first form requires the > > Oh, good grief. If the language specification says > they have the same result, then they can be implemented > the same way. _I_ certainly will never specify "these > must have the same result, but you must do extra work > on that one." Oh, good grief yourself. If A and B are matrices, then A := A + B and A += B give the same result, but the latter, if properly implemented, is indeed substantially more efficient than the former. Once again, I will explain why. The first form requires the creation of a temporary matrix to hold the sum, then a copy from the temporary back to A. The second form, on the other hand, can do the addition in place in A on an element by element basis, eliminating the need for the temporary matrix and the copy operation. And no, the first form cannot be implemented the same as the second. When you use the first form, you are indeed telling the compiler "you must do extra work on that one," as you put it. In some small programs the more natural first form may be perfectly adequate, but certainly not in computationally intensive numerical programs. If you still don't get it, think about how you would implement A := B + C + D. Each intermediate sum needs its own temporary. The more efficient form would be A := B A += C A += D I don't care whether the operator is called += or something else, but Ada needs it badly, along with -=, *=, and /= (or equivalent, I realize that symbol is taken). Their absence is a glaring omission in Ada.