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!aioe.org!.POSTED!not-for-mail From: "Dmitry A. Kazakov" Newsgroups: comp.lang.ada Subject: Re: How to get Ada to ?cross the chasm?? Date: Wed, 2 May 2018 16:36:56 +0200 Organization: Aioe.org NNTP Server 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> <87lgd23zm0.fsf@nightsong.com> NNTP-Posting-Host: MyFhHs417jM9AgzRpXn7yg.user.gioia.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Complaints-To: abuse@aioe.org User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 X-Notice: Filtered by postfilter v. 0.8.3 Content-Language: en-US Xref: reader02.eternal-september.org comp.lang.ada:51917 Date: 2018-05-02T16:36:56+02:00 List-Id: On 02/05/2018 16:23, Paul Rubin wrote: > "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. That is the operator's name, e.g. function "+" (Left, Right : Integer) return Integer; > It also looks like you can add up booleans, where true=1 and false=0? Boolean'Pos (X) returns universal integer. Boolean'Pos (False) = 0, Boolean'Pos (True) = 1. So the kludge sums all True outcomes of Is_Operation_Output. So it is possible to decipher, but that is by no means Ada (TM). -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de