comp.lang.ada
 help / color / mirror / Atom feed
From: mfeldman@seas.gwu.edu (Michael Feldman)
Subject: Re: LRM 4.1.3 paragraphs 17-19
Date: 11 Feb 91 14:57:26 GMT	[thread overview]
Message-ID: <2704@sparko.gwu.edu> (raw)
In-Reply-To: 1991Feb09.023913.524@mojsys.com

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

  reply	other threads:[~1991-02-11 14:57 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1991-02-08  6:34 Ada Test Tools Scott Layson
1991-02-09  2:39 ` LRM 4.1.3 paragraphs 17-19 Joe Vlietstra
1991-02-11 14:57   ` Michael Feldman [this message]
1991-02-12  9:48     ` (George C. Harrison) Norfolk State University
1991-02-12 19:13       ` Michael Feldman
1991-02-12 21:44         ` Billy Yow 283-4009
1991-02-13  4:32           ` Michael Feldman
1991-02-13 16:32             ` jncs
1991-02-15  4:11     ` Jim Showalter
  -- strict thread matches above, loose matches on Subject: below --
1991-02-14  3:41 Michael Feldman
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox