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-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,90514f9a192a4997 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-09-05 12:32:31 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!headwall.stanford.edu!newshub.sdsu.edu!elnk-nf2-pas!newsfeed.earthlink.net!stamper.news.pas.earthlink.net!newsread4.news.pas.earthlink.net.POSTED!not-for-mail From: Jeffrey Carter Organization: jrcarter commercial-at acm [period | full stop] org User-Agent: Mozilla/5.0 (Windows; U; Win98; en-US; rv:1.4) Gecko/20030624 X-Accept-Language: en-us, en MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Expectation of Access Value Equality References: In-Reply-To: Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Message-ID: Date: Fri, 05 Sep 2003 19:32:31 GMT NNTP-Posting-Host: 63.184.105.111 X-Complaints-To: abuse@earthlink.net X-Trace: newsread4.news.pas.earthlink.net 1062790351 63.184.105.111 (Fri, 05 Sep 2003 12:32:31 PDT) NNTP-Posting-Date: Fri, 05 Sep 2003 12:32:31 PDT Xref: archiver1.google.com comp.lang.ada:42189 Date: 2003-09-05T19:32:31+00:00 List-Id: Nick Roberts wrote: > I'm asking for the help of Ada programmers of all levels of experience. > > Given the following declarations: > > type A_String is access constant String; > > function "+" (S: String) return A_String is > begin > return new String'(S); > end; > > type A_String_Array is array (Positive range <>) of String; Later corrected this line with: > I'm sorry, I did mean: > > type A_String_Array is array (Positive range <>) of A_String; > > procedure Print (A: in A_String_Array) is > Sentinel: constant A_String := A(A'Last); > Current: Positive := A'First; > begin > loop > Put_Line( A(Current).all ); > exit when A(Current) = Sentinel; > Current := Current + 1; > end loop; > end; My reaction is to wonder why you're not using a for loop here: for Current in A'range loop If you can come up with a real example where this is relevant, it would make the answers of greater interest. At first glance, I'd expect both examples to print 4 lines. If an implementation didn't give that behavior, though, I suspect I'd look further at the fact that you're using "access constant", so the compiler could save only a single copy of the duplicated values, and use the same access value for equal strings. Both results (4 lines or fewer than 4 lines) seem legal. > (d) I'd be grateful for a very brief indication of your level and broad > area(s) of programming experience, in Ada and other languages. I've been using Ada since 1984; I'm not a language lawyer or compiler writer, but I think I have a pretty good understanding of the language. I've also used a number of other languages, including BASICs, Pascals, FORTRAN-66, COBOL, C, and assemblers. -- Jeff Carter "You couldn't catch clap in a brothel, silly English K...niggets." Monty Python & the Holy Grail 19