comp.lang.ada
 help / color / mirror / Atom feed
From: Phil Thornley <phil.jpthornley@gmail.com>
Subject: Re: Question about out parameters of unconstrained array type.
Date: Sun, 26 Feb 2012 13:20:46 -0000
Date: 2012-02-26T13:20:46+00:00	[thread overview]
Message-ID: <MPG.29b4420de07b053f98968c@news.zen.co.uk> (raw)
In-Reply-To: 20120226132532.7fb8ec1b@t60

In article <20120226132532.7fb8ec1b@t60>, mail@senier.net says...
> 
> On Sun, 26 Feb 2012 09:14:53 -0000
> Phil Thornley <phil.jpthornley@gmail.com> 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






  reply	other threads:[~2012-02-26 13:20 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-02-25 15:19 Question about out parameters of unconstrained array type Peter C. Chapin
2012-02-25 15:33 ` Dmitry A. Kazakov
2012-02-25 18:20 ` Phil Thornley
2012-02-25 20:01   ` Simon Wright
2012-02-25 22:44     ` Phil Thornley
2012-02-27 13:48       ` Mark Lorenzen
2012-02-27 15:32         ` Phil Thornley
2012-02-25 23:37   ` Alexander Senier
2012-02-26  1:16   ` Peter C. Chapin
2012-02-26  9:14     ` Phil Thornley
2012-02-26 12:25       ` Alexander Senier
2012-02-26 13:20         ` Phil Thornley [this message]
2012-02-26 14:25         ` Niklas Holsti
2012-02-26 17:32         ` Jeffrey Carter
2012-02-26 15:29       ` Peter C. Chapin
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox