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=unavailable autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!feeder.eternal-september.org!nntp-feed.chiark.greenend.org.uk!ewrotcd!newsfeed.xs3.de!io.xs3.de!news.jacob-sparre.dk!franka.jacob-sparre.dk!pnx.dk!.POSTED.rrsoftware.com!not-for-mail From: "Randy Brukardt" Newsgroups: comp.lang.ada Subject: Re: How to get Ada to ?cross the chasm?? Date: Tue, 1 May 2018 17:32:21 -0500 Organization: JSA Research & Innovation Message-ID: References: <1c73f159-eae4-4ae7-a348-03964b007197@googlegroups.com> <87k1su7nag.fsf@nightsong.com> <87po2la2qt.fsf@nightsong.com> <87in8buttb.fsf@jacob-sparre.dk> <87wowqpowu.fsf@nightsong.com> <16406268-83df-4564-8855-9bd0fe9caac0@googlegroups.com> <87o9i2pkcr.fsf@nightsong.com> <87bme2oy91.fsf@nightsong.com> <877eoom26h.fsf@nightsong.com> <1c4c7bd9-fa68-4ea2-8419-098becb6993e@googlegroups.com> Injection-Date: Tue, 1 May 2018 22:32:22 -0000 (UTC) Injection-Info: franka.jacob-sparre.dk; posting-host="rrsoftware.com:24.196.82.226"; logging-data="18345"; mail-complaints-to="news@jacob-sparre.dk" X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.5931 X-RFC2646: Format=Flowed; Original X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.7246 Xref: reader02.eternal-september.org comp.lang.ada:51895 Date: 2018-05-01T17:32:21-05:00 List-Id: wrote in message news:1c4c7bd9-fa68-4ea2-8419-098becb6993e@googlegroups.com... >> > Well there are also loops etc. If you want to make a new array whose >> > elements are the squares of all the elements of an old array, you end >> > up >> > writing a loop. >> >> But I don't want it. There is no practical need in array operations >> using arrays as a whole. > >Programmers in R do it all the time (leading to very convoluted code!) > because they discover sooner or later that loops with many iterations, > or worse, nested loops, kill the performance of their programs. Perhaps > it's the case with other script languages. I've seen series of complicated >array operations in Python just for the sake of avoiding a trivial loop. In > the end it's still much slower than Ada, but the script programmers > knowing only their language have the satisfaction of having "optimized" > their code. And better, this is likely coming to Ada 2020 using the 'Reduce attribute (see AI12-0242-1 and AI12-0262-1). Some of the examples justifying this feature are quite maddening. For instance: Num_Outputs : constant Natural := (for P of Formal_Params => Boolean'Pos(P.Is_Operation_Output))'Reduce("+",0); -- Count "in out" and "out" parameters in a parameter list. Cool, but is this really making the code more readable? Put_Line("[" & (for I in Inputs'Range => (if I = Inputs'First then "" else ", ") & "VN" & Inputs(I)) & "]"); -- Display a properly formatted list of inputs. Again, wouldn't this have been better written as a function rather than a one-liner? And using "reduce" for string *construction* seems confusing at best (nothing is being reduced here). This should let Paul write the kind of code that he wants to write; whether one really gets the benefits of Ada from doing so is another question altogether. Randy. P.S. The reason this feature is being considered is that it is easily executed in parallel; and a lot of loops are better written this way as it avoids the need for an accumulator in a parallel loop, which necessarily needs some sort of synchronization.