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-03 10:58:21 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: 3 Jun 2003 10:58:20 -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> <7vfzmr60r5.fsf@vlinux.voxelvision.no> NNTP-Posting-Host: 128.102.146.44 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Trace: posting.google.com 1054663101 23550 127.0.0.1 (3 Jun 2003 17:58:21 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: 3 Jun 2003 17:58:21 GMT Xref: archiver1.google.com comp.lang.ada:38528 Date: 2003-06-03T17:58:21+00:00 List-Id: Ole-Hjalmar Kristensen wrote in message news:<7vfzmr60r5.fsf@vlinux.voxelvision.no>... > 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? How would that work? Remember, my overloaded "+" operator could do anything. For example, I could be using it for quaternion "addition," which follows very different rules from conventional matrix addition. Think also of how it would deal with chained addition, e.g., A := B + C + D + E. Your suggestion would require some sort of advanced artificial intelligence to be built in to the compiler. The AI system would need to perform a very complex analysis of the overloaded "+" operator and decide how to deal with it. The only other alternative would be to have the "+" operator automatically defined for arrays. Either approach would constitute a major change in philosophy for Ada.