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-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,38fc011071df5a27 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-06-03 01:09:55 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!logbridge.uoregon.edu!news.tele.dk!news.tele.dk!small.news.tele.dk!uninett.no!dax.net!juliett.dax.net!not-for-mail Newsgroups: comp.lang.ada Subject: Re: Ideas for Ada 200X 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> From: Ole-Hjalmar Kristensen Message-ID: <7vfzmr60r5.fsf@vlinux.voxelvision.no> User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.1 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Date: Tue, 03 Jun 2003 08:09:19 GMT NNTP-Posting-Host: 193.216.12.150 X-Complaints-To: abuse@tele2.no X-Trace: juliett.dax.net 1054627759 193.216.12.150 (Tue, 03 Jun 2003 10:09:19 MET DST) NNTP-Posting-Date: Tue, 03 Jun 2003 10:09:19 MET DST Organization: Tele2 Norway AS Public Access Xref: archiver1.google.com comp.lang.ada:38440 Date: 2003-06-03T08:09:19+00:00 List-Id: 18k11tm001@sneakemail.com (Russ) writes: > 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. > Where in the standard is this temporary matrix required? Look at it this way: you are telling the computer to assign the sum of A and B to A. Why isn't the compiler free to do the addition in place, unless you have got an overloaded "+" with strange side effects? > 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. > -- Ole-Hj. Kristensen ****************************************************************************** * You cannot consistently believe this sentence. ******************************************************************************