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: a07f3367d7,e276c1ed16429c03 X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news3.google.com!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: "Vinzent Hoefler" Newsgroups: comp.lang.ada Subject: Re: Ada is getting more popular! Date: Thu, 14 Oct 2010 01:05:34 +0200 Message-ID: References: <020ea727-e8e9-4d0d-8c5f-b8ad907fc3c9@u10g2000yqk.googlegroups.com> <8edaf552-0104-4150-bb55-5557e8e24be3@i5g2000yqe.googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed; delsp=yes Content-Transfer-Encoding: 7bit X-Trace: individual.net OatKDpf93bqopRItP8bp1wJ6xTrOPKNbfuy0bR9s+pof4yMokK Cancel-Lock: sha1:85amjvlySHPrBxxw0IyOQQmsHiU= User-Agent: Opera Mail/10.62 (Win32) Xref: g2news2.google.com comp.lang.ada:15496 Date: 2010-10-14T01:05:34+02:00 List-Id: On Thu, 14 Oct 2010 00:49:40 +0200, ramon_garcia wrote: > On Oct 14, 12:34 am, "Vinzent Hoefler" domaingrabbing.de> wrote: >> Huh? Since when do "out" parameters imply a copy? > > If the size is determinated at runtime, the caller cannot know the > size in advance, and cannot allocate it. In fact, GNAT has a > "secondary stack" for returning variable-size objects. For functions returning such types, yes. Not for procedures. >> I don't understand that. Either you are creating the array >> dynamically, then getting an access to it should not be a problem >> or the caller already knows the bounds. > > The array was created statically, but I do not want code in the caller > to depend on that. type Buffer is array (Positive range <>) of ...; type Buffer_Access is access all Buffer; A : Buffer := (1 .. 4 => ...); P : Buffer_Access := A'Access; should work, while A : Buffer (1 .. 4); P : Buffer_Access := A'Access; does not. > Or a container record was created dynamically, and the size of the > array is part of the discriminant. > > type container(n_elemen: natural) is record > a: buffer(n_elemen); > end record; In that case you lose, because you cannot create A without explicit bounds. And with explicit bounds, the x.A'Access won't do. > Imagine that this type is defined in the private part of the package. > A method is provided to obtain an access to the buffer, and from that > access the bounds of the array can be obtained at run time. This is > not posible in general. Why don't you provide access to the record then? Vinzent. -- There is no signature.