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.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,fd3a5ba6349a6060 X-Google-Attributes: gid103376,public From: Joel Seidman Subject: Re: should I be interested in ada? Date: 1999/02/18 Message-ID: <36CC7576.F3D5DA5C@trw.com>#1/1 X-Deja-AN: 445811895 Content-Transfer-Encoding: 7bit References: <7a72e6$g55$1@probity.mcc.ac.uk> <36C93BB4.1429@ecs.soton.ac.uk> <7afc1o$3mi$2@plug.news.pipex.net> <7afttr$7v3$1@nnrp1.dejanews.com> <7aganu$qsc$1@plug.news.pipex.net> <36CC11A1.C7A71642@hercii.mar.lmco.com> <7ahkn0$kab$1@plug.news.pipex.net> Content-Type: text/plain; charset=iso-8859-2 Organization: TRW, Inc. Mime-Version: 1.0 Newsgroups: comp.lang.ada Date: 1999-02-18T00:00:00+00:00 List-Id: Nick Roberts wrote: > > Jerry Petrey wrote in message <36CC11A1.C7A71642@hercii.mar.lmco.com>... > [...] > |> Fortran's array facilities as an example, in Fortran one can put: > |> > |> real, dimension (1:10) :: x > |> ... > |> x = 1.0 > |> > |> setting all the elements of x to 1.0 (a 'broadcast scalar'), whereas in > Ada > |> to do the same thing, you must code something like: > |> > |> X: array (1..10) of Float; > |> ... > |> for i in X'Range loop X(i) := 1.0; end loop; > | > | > |I think using an aggregate would be much better than a loop: > | > |X := (1 .. 10 => 1.0); > > Precisely right, of course. > Hmmmm. This raises a question about what "better" means. I have seen the latter recommended for style, and it does read better to me. However, when I applied this to large aggregates, stack utilization went throught the roof. The compiler (VADS) created a temp and then moved it on top of the target variable. I quickly learned to use this method only where the aggregate couldn't be too large. I'm really not sure why VADS does this. Is it typical of Ada compilers? Or was VADS failing to do a fairly obvious optimization. (To be fair, this was an old version of VADS. I haven't tried this with our current compiler.) -- Joel