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,f51e93dacd9c7fca X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-06-18 02:36:30 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!skynet.be!skynet.be!transit.news.xs4all.nl!not-for-mail From: Fraser Wilson Newsgroups: comp.lang.ada Subject: Re: status of Ada STL? Date: 18 Jun 2002 11:37:48 +0200 Organization: XS4ALL Internet BV Sender: fwilson@FWILSON Message-ID: References: <3d0ce154_5@news.bluewin.ch> NNTP-Posting-Host: a80-126-24-12.adsl.xs4all.nl X-Trace: news1.xs4all.nl 1024392988 15390 80.126.24.12 (18 Jun 2002 09:36:28 GMT) X-Complaints-To: abuse@xs4all.nl NNTP-Posting-Date: 18 Jun 2002 09:36:28 GMT X-Newsreader: Gnus v5.7/Emacs 20.7 Xref: archiver1.google.com comp.lang.ada:26219 Date: 2002-06-18T09:36:28+00:00 List-Id: 18k11tm001@sneakemail.com (Russ) writes: > By the way, it's too bad that Ada wasted "/=" on "not equals. It would > be very useful for dividing a matrix by a scalar. For example, the > construct > > A := A / 2.0; > > is very inefficient because a temporary matrix must be created to > store A/2, then an assignment must be used to put the result back in > A. On the other hand, > the construct > > A /= 2.0 > > is not only much cleaner looking, it is much more efficient because > you can skip the temporary matrix and the assignment. And please don't > argue with me here, because you will only be showing your ignorance. C++ seems to tie itself in knots over the issue of temporaries, which is why constructs such as the above have to be used. Is it because of the class/constructor/destructor thing? I don't know, but it's always seemed odd that programmers of this language get so caught up in it. In any case, Ada has a different type model, and, even in the case of matrices, the expression "A := A / 2.0" can, in many situations, be optimised by the compiler to avoid temporaries. I'm not saying they do, but they can, and it's not particularly difficult as optimisations go. Look, I'll write some pseudo code: if the assignment expression looks like "X := X Y", X is of type T, T is big, and T, are declared in a pure package, put the address of X on the stack and call the non-temporary version of . When compiling operators of a big type in a pure package, create a non-temporary version of each suitable operator, and have a standard version which calls that. Alternatively, you could just pragma Inline these things, which will also eliminate temporaries (I expect). I'd much rather write my assignments in a natural and readable manner ("A becomes A divided by 2") than worry about arcane compiler temporary issues. > Good C++ programmers know all about this. Ada programmers don't have to! Fraser.