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,5b3aa4bc9027f04e X-Google-Attributes: gid103376,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!postnews.google.com!v35g2000pro.googlegroups.com!not-for-mail From: Adam Beneschan Newsgroups: comp.lang.ada Subject: Re: Unconstrained Arrays Date: Wed, 25 Mar 2009 15:03:36 -0700 (PDT) Organization: http://groups.google.com Message-ID: <0348afd0-223e-44bb-9b5d-80b02b38365e@v35g2000pro.googlegroups.com> References: <1a8008fb-c840-45bc-824c-d10eec9fe569@d36g2000prf.googlegroups.com> <0caa9cf8-0620-4544-9b2c-2c9f24142b7f@v23g2000pro.googlegroups.com> <386b0e00-a1c6-4c5f-adf7-89b8543d0e2d@c11g2000yqj.googlegroups.com> <46281cbb-2804-41e8-87a0-251c9060d4d1@c36g2000yqn.googlegroups.com> <000dc793-a278-4379-b44e-e5aa7375b0fc@e38g2000yqa.googlegroups.com> NNTP-Posting-Host: 66.126.103.122 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Trace: posting.google.com 1238018617 26873 127.0.0.1 (25 Mar 2009 22:03:37 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Wed, 25 Mar 2009 22:03:37 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: v35g2000pro.googlegroups.com; posting-host=66.126.103.122; posting-account=duW0ogkAAABjRdnxgLGXDfna0Gc6XqmQ User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.7.12) Gecko/20050922 Fedora/1.7.12-1.3.1,gzip(gfe),gzip(gfe) Xref: g2news1.google.com comp.lang.ada:4316 Date: 2009-03-25T15:03:36-07:00 List-Id: On Mar 25, 2:21 pm, sjw wrote: > On Mar 20, 3:45 pm, Adam Beneschan wrote: > > > On Mar 19, 11:45 pm, sjw wrote: > > Hope this helps explain things. In any case, I strongly agree with > > everyone else that using pointers in the OP's particular situation is > > the wrong approach, and there shouldn't be any reason for it except > > perhaps to work around a poor compiler implementation. > > Thanks for the explanation. > > My current problem is with this .. > > type Stream_Type > (Buffer : access Ada.Streams.Stream_Element_Array) > is new Ada.Streams.Root_Stream_Type with private; > -- Provides an in-memory Stream over the elements of Buffer. > -- > -- When one of these Stream_Types is created, it is notionally > -- empty. If Buffer is not in fact empty (perhaps it has been read > -- from a datagram socket), use Set_Last to indicate the index of > -- the last valid element. > > where having to initialize a buffer of size 2048 (say) with useless > data and then overwrite it by reading from a socket goes against the > grain. Perhaps I'll be able to find the Ada way of doing it and it > will be suitably elegant. Well, you can initialize it with garbage data instead of useless data: Buffer : aliased Ada.Streams.Stream_Element_Array := (1 .. 2048 => <>); A minor improvement, maybe. I do think this is clunky, though, but I don't know what the answer is. A worse problem is that there are contexts where this workaround is disallowed. -- Adam