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=ham 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.211.38 with SMTP id mz6mr542805pbc.1.1330259134089; Sun, 26 Feb 2012 04:25:34 -0800 (PST) Path: h9ni11238pbe.0!nntp.google.com!news1.google.com!goblin1!goblin.stu.neva.ru!eternal-september.org!feeder.eternal-september.org!mx04.eternal-september.org!.POSTED!not-for-mail From: Alexander Senier Newsgroups: comp.lang.ada Subject: Re: Question about out parameters of unconstrained array type. Date: Sun, 26 Feb 2012 13:25:32 +0100 Organization: A noiseless patient Spider Message-ID: <20120226132532.7fb8ec1b@t60> References: <4NedncPWdPN9GtTS4p2dnAA@giganews.com> Mime-Version: 1.0 Injection-Info: mx04.eternal-september.org; posting-host="e6Gu2UbyOy2nuiHyFRTtfw"; logging-data="31771"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+CwDsNF8oUrdQEhtUfgeQY" X-Newsreader: Claws Mail 3.7.9 (GTK+ 2.24.6; x86_64-pc-linux-gnu) Cancel-Lock: sha1:3J8k50c44HCDVCNIacEZoYciwZM= Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Date: 2012-02-26T13:25:32+01:00 List-Id: 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 ;-( Regards Alex