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-04 09:54:51 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!logbridge.uoregon.edu!hammer.uoregon.edu!skates!not-for-mail From: Stephen Leake Newsgroups: comp.lang.ada Subject: Re: Ideas for Ada 200X Date: 04 Jun 2003 12:54:31 -0400 Organization: NASA Goddard Space Flight Center (skates.gsfc.nasa.gov) 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> <3EDCBDF4.1050900@attbi.com> NNTP-Posting-Host: anarres.gsfc.nasa.gov Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: skates.gsfc.nasa.gov 1054746641 29888 128.183.235.92 (4 Jun 2003 17:10:41 GMT) X-Complaints-To: usenet@news.gsfc.nasa.gov NNTP-Posting-Date: 4 Jun 2003 17:10:41 GMT User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3 Xref: archiver1.google.com comp.lang.ada:38620 Date: 2003-06-04T17:10:41+00:00 List-Id: 18k11tm001@sneakemail.com (Russ) writes: > "Robert I. Eachus" wrote in message news:<3EDCBDF4.1050900@attbi.com>... > > What if Ada did allow: > > > > A += B; ? > > > > Then the Ada rules would still require that A be unchanged if > > Constraint_Error was raised, so there would be an intermediate. Of > > course, a compiler could 'unwind' the partial addition by subtraction to > > produce the required result. It would be an interesting optimization, > > but AFAIK, no Ada compiler does it. > > Well, it seems to me that such an "interesting optimization" might be > well worth doing. Then again, the "unwind" operation would obviously > depend on the definition of the "+=" operation, which could be > different for each type, so I don't see how it could be done in > general. That is the point; since it can't be done in general, it's not a good idea to put it in the language in the hope that it will be done for some particular cases. > In any case, the performance hit taken to keep A unchanged when a > Constraint_Error is raised seems rather expensive to me. If it were > up to me, I would take the factor of four better efficiency over > preserving A in the rare case of an overflow. And I'll bet most > programmers doing heavy-duty number crunching for simulation would > too. Yes. And they will write a matrix library that does it. > I know that Ada is preferable for safety-critical applications, but > based on what you are telling me, it sure seems to be a poor choice > for non-safety-critical simulation with heavy number crunching. That's nonsense. Clearly an efficient matrix library can be written in Ada. We are only talking about whether the syntax Matrix_Add (To => A, Add => B); is "better" in some sense than the syntax A += B; Ignoring the Constraint_Error handling discussed above, these two statements have identical run-time behavior; they both call the same routine. You are arguing that is what Ada should do. Then it is only when writing and reading the code that there is a difference. Someone doing heavy-duty number crunching shouldn't care about this level of syntax choice. In fact, they will even use Fortran, if that is the only compiler available for the fastest machine they have. (Hmm. Does Fortran now have += ?). The designers of Ada (and many users of Ada) think Matrix_Add is better, partly because they placed emphasis on reading, partly because it is clear that the programmer decides the semantics with respect to Constraint_Error etc. You (and many others) think += is better, partly because you mistakenly believe it allows the code to be more run-time efficient, and partly because you are familiar with it in C and C++. > Thanks for clarifying that. I guess C++ is good for something after > all, eh? Apparently it's good for generating endless discussions on comp.lang.ada :). -- -- Stephe