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=0.7 required=5.0 tests=BAYES_00,FORGED_GMAIL_RCVD, FREEMAIL_FROM,REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,bc2c82b1e5c6fe83 X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Received: by 10.68.241.37 with SMTP id wf5mr8306357pbc.4.1330262447093; Sun, 26 Feb 2012 05:20:47 -0800 (PST) Path: h9ni11386pbe.0!nntp.google.com!news1.google.com!goblin2!goblin3!goblin.stu.neva.ru!news.franciliens.net!news.muarf.org!nntpfeed.proxad.net!proxad.net!feeder2-2.proxad.net!zen.net.uk!hamilton.zen.co.uk!prichard.zen.co.uk.POSTED!not-for-mail From: Phil Thornley Newsgroups: comp.lang.ada Subject: Re: Question about out parameters of unconstrained array type. Date: Sun, 26 Feb 2012 13:20:46 -0000 Message-ID: References: <4NedncPWdPN9GtTS4p2dnAA@giganews.com> <20120226132532.7fb8ec1b@t60> Reply-To: phil.jpthornley@gmail.com MIME-Version: 1.0 User-Agent: MicroPlanet-Gravity/3.0.4 Organization: Zen Internet NNTP-Posting-Host: 39f5940c.news.zen.co.uk X-Trace: DXC=MbBSn94K0k^TM0WAaIh?=Z0g@SS;SF6nWR9OH0:RnENT@KAF>7^kH^^gPN:7kYdTY[6kOG`?Xa0dP X-Complaints-To: abuse@zen.co.uk Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Date: 2012-02-26T13:20:46+00:00 List-Id: In article <20120226132532.7fb8ec1b@t60>, mail@senier.net says... > > On Sun, 26 Feb 2012 09:14:53 -0000 > Phil Thornley wrote: > > > For your code above, if the cost of including the initialization of the > > array is too high then the easiest way to remove the the error is > > probably to add another parameter that is the length of the Description > > string. Using Alexander's code: > > Can anybody comment on the legality of using attributes of an out parameter of > an unconstrained (array) type in Ada? A brief skim through LRM could not > enlighten me... > > If using 'Length (and other attributes) elsewhere than in a loop constraint > actually is legal Ada, than this seems like an unnecessary limitation of SPARK > that should be relaxed. For now, I would prefer accepting the resulting flow > error for several reasons: > > * Default initialization may hide subsequent flow errors that would > been spotted by the flow analysis otherwise (the coarse grained treatment > of array makes that less important, though) > > * As Phil said, (additional) default initialization may impose a significant > performance overhead > > * Passing in the upper bound of the array as a parameter IMHO makes the code > less intuitive and readable than it could be - just to silence the flow > analysis ;-( > I fully agree with all of this. It looks as if the statement in Section 4.1 of the LRM: "... the name of an unconstrained array object (formal parameter) shall only appear in the following contexts: 1 as the prefix of an attribute reference; 2 ..." needs some qualification. (I can't find anything in the release notes to suggest that this is already seem as a deficiency in the language or tool.) Cheers, Phil