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,FREEMAIL_FROM, WEIRD_QUOTING 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-10 11:39:57 PST Path: archiver1.google.com!postnews1.google.com!not-for-mail From: amado.alves@netcabo.pt (=?ISO-8859-1?Q?M=E1rio_Amado_Alves?=) Newsgroups: comp.lang.ada Subject: Re: Expectation of Access Value Equality Date: 10 Sep 2003 11:39:56 -0700 Organization: http://groups.google.com/ Message-ID: <17eddf9f.0309101039.146e6e28@posting.google.com> References: NNTP-Posting-Host: 212.113.164.98 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Trace: posting.google.com 1063219197 19586 127.0.0.1 (10 Sep 2003 18:39:57 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: 10 Sep 2003 18:39:57 GMT Xref: archiver1.google.com comp.lang.ada:42356 Date: 2003-09-10T18:39:57+00:00 List-Id: "Nick Roberts" wrote in message news:... > 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 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; > > (a) Would you be surprised by: > > Print( (+"foo",+"bar",+"",+"") ); > > printing three lines? Yes. > (b) Would you be surprised by: > > Print( (+"foo",+"bar",+"hum",+"foo") ); > > printing one line? Yes. > (c) What would you think of an implementation that caused this behaviour? I would think the behaviour was not in accordance with the deep, natural meaning of "new". I would suspect the system was trying to reuse memory, at the cost of some search time. And I would hope this behaviour was a compiler option. And wish it was not the default. > (What would you think of an implementation that printed four lines in both > cases?) All is well. > (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'm programming since 1984, in Ada since 1997, and before it was in BASIC, Assembler, Clipper, QuickBASIC, Pascal, C, C++, Java... I'm an academic now but I have worked for industry and sometimes I still do freelance work.