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=0.7 required=5.0 tests=BAYES_00,INVALID_DATE, MSGID_SHORT,REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 Path: utzoo!utgpu!news-server.csri.toronto.edu!rutgers!cmcl2!yale!think.com!spool.mu.edu!uunet!seas.gwu.edu!mfeldman From: mfeldman@seas.gwu.edu (Michael Feldman) Newsgroups: comp.lang.ada Subject: Re: LRM 4.1.3 paragraphs 17-19 Keywords: expanded name Message-ID: <2704@sparko.gwu.edu> Date: 11 Feb 91 14:57:26 GMT References: <1991Feb8.063458.850@kestrel.edu> <1991Feb09.023913.524@mojsys.com> Reply-To: mfeldman@seas.gwu.edu () Distribution: usa Organization: The George Washington University, Washington D.C. List-Id: In article <1991Feb09.023913.524@mojsys.com> joevl@mojsys.com (Joe Vlietstra) writes: >Loop statements implicitly declare a variable: the loop index. >So the following works (but may get the programmer fired): > LOOP1: > for I in 1..10 loop > LOOP2: > for I in 1..10 loop > X (LOOP1.I,LOOP2.I) := 100.0; > end loop LOOP2; > end loop LOOP1; >But LOOP1.I cannot be referenced outside of the loop. Perhaps this will start a new thread. I'd fire the programmer for two reasons (I presume Joe had both reasons in mind): 1. using the same name for the two loop indices is gratuitously obscure (thus violates a common-sense style principle); it doesn't even save a variable in this case. 2. IMHO one shouldn't use a loop like this in Ada to begin with, to clear an array to a single value. An aggregate like X := (others => (others => 100.0)); expresses the intention of the programmer more clearly not only to the human reader but also to the compiler, which can - perhaps - generate better code accordingly. What I figure could start a new thread is this: in your experience, what are the sequential Ada constructs that (may) lead to _better_ optimized code than the "old way" would?IMHO aggregates, universal assignment (i.e. assignment operator for structured types) and universal equality are three such things. Which others? What is the actual experience with code generators? Do they exploit this possible optimization (yet)? If I am correct, we in the Ada community should be using these arguments to rebut the arguments of the anti-Ada crowd that Ada code is _necessarily_ worse than its equivalent in (pick your other language). I believe that Ada code is not only non-worse, it has the potential to be considerably better once the compilers and the programmers catch on. Am I correct? Mike