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.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,6d748e86b56b1269 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-01-28 06:43:26 PST Path: archiver1.google.com!news2.google.com!news1.google.com!newsfeed.stanford.edu!nntp.cs.ubc.ca!newsflash.concordia.ca!snoopy.risq.qc.ca!chi1.webusenet.com!news.webusenet.com!cyclone1.gnilink.net!wn12feed!worldnet.att.net!bgtnsc04-news.ops.worldnet.att.net.POSTED!not-for-mail Reply-To: "James S. Rogers" From: "James S. Rogers" Newsgroups: comp.lang.ada References: <5ad0dd8a.0301270746.6ad4c4b0@posting.google.com> <5ad0dd8a.0301271851.7c907f60@posting.google.com> <5ad0dd8a.0301280414.6ac8d45e@posting.google.com> Subject: Re: Prefix to 'ACCESS must either statically match... But why? X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1106 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 Message-ID: Date: Tue, 28 Jan 2003 14:43:25 GMT NNTP-Posting-Host: 12.86.32.218 X-Complaints-To: abuse@worldnet.att.net X-Trace: bgtnsc04-news.ops.worldnet.att.net 1043765005 12.86.32.218 (Tue, 28 Jan 2003 14:43:25 GMT) NNTP-Posting-Date: Tue, 28 Jan 2003 14:43:25 GMT Organization: AT&T Worldnet Xref: archiver1.google.com comp.lang.ada:33488 Date: 2003-01-28T14:43:25+00:00 List-Id: "Wojtek Narczynski" wrote in message news:5ad0dd8a.0301280414.6ac8d45e@posting.google.com... > > Why are you choosing to pass an access to a Stream_Element_Array > > instead of just the Stream_Element_Array? Avoiding the use of an > > access type would also eliminate the problem. Remember that any > > parameter, even an IN parameter can be passed by reference by the > > compiler. In fact, an array object is most frequently passed by > > reference. > > Because this function uses 'Unrestricted_Access to return an array of > accecceses to slices of the parameter array. This is supposed to yeld > in better speed and compactness, and let me avoid heap allocations. If > I were to copy the strings out of this huge array I'd have to allocate > them on heap. Since this is a parameter array, why not merely return an array of index pairs? The index pairs can index the beginning and end of each array slice. The idea of returning a set of "pointers" to pieces of an array is very common in C, where pointer arithmetic is tied to array indexing. In Ada there is no corresponding tie between access types and array indexing. If you want an index, then use an index. This difference between C and Ada is made easier to use due to Ada's array slicing capabilities, which are not directly implemented in C. > > >> And in general I find the inablility to declare access type > >> subtypes in parallel with the subtypes for the designated > >> type obstructive. > > > > It appears that you are thinking in C while programming in Ada. > > Heh, maybe. Please take a look at my other post - even the compilers > are unsure if what I've written is Ada ;-) Jim Rogers