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!.POSTED!not-for-mail From: Paul Rubin Newsgroups: comp.lang.ada Subject: Re: How to get Ada to ?cross the chasm?? Date: Wed, 02 May 2018 07:23:51 -0700 Organization: A noiseless patient Spider Message-ID: <87lgd23zm0.fsf@nightsong.com> 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> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: reader02.eternal-september.org; posting-host="c542ccd1be7cc45dffb8a8de81e34fd0"; logging-data="14155"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/s/f6XJ1A0yFI+umEC+lO0" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.3 (gnu/linux) Cancel-Lock: sha1:5D3eAvWnQNxoWfbIZyLF4FDSCxc= sha1:KsjeFncFQW0gTzERq3blcLSAKkY= Xref: reader02.eternal-september.org comp.lang.ada:51915 Date: 2018-05-02T07:23:51-07:00 List-Id: "Randy Brukardt" writes: > 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? Is that some kind of syntactic extension in the compiler? I'm used to reduce being an ordinary function. But "+" in double quotes looks like a character string, so the compiler must be figuring out what it does. It also looks like you can add up booleans, where true=1 and false=0? That is also surprising, if booleans are a separate type from integers. > 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). On the surface that looks like what other languages call a list comprehension. But then it seems to be concatenating all those strings? So it's reducing a concatenation operation over the list of strings. I agree that it looks confusing in Ada. If the goal was only to support parallel evaluation, there were probably easier ways. > This should let Paul write the kind of code that he wants to write; It's too syntactically clumsy to be convenient, but besides the parallelism benefit, it might also be easier to formally verify than an explicit loop would be.