From: amado.alves@netcabo.pt (Mário Amado Alves)
Subject: Re: Expectation of Access Value Equality
Date: 10 Sep 2003 11:39:56 -0700
Date: 2003-09-10T18:39:57+00:00 [thread overview]
Message-ID: <17eddf9f.0309101039.146e6e28@posting.google.com> (raw)
In-Reply-To: bja3fi$glkjh$1@ID-25716.news.uni-berlin.de
"Nick Roberts" <nickroberts@blueyonder.co.uk> wrote in message news:<bja3fi$glkjh$1@ID-25716.news.uni-berlin.de>...
> 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.
next prev parent reply other threads:[~2003-09-10 18:39 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-09-05 13:35 Expectation of Access Value Equality Nick Roberts
2003-09-05 13:02 ` chris
2003-09-05 17:56 ` Nick Roberts
2003-09-05 19:10 ` Robert I. Eachus
2003-09-05 19:32 ` Jeffrey Carter
2003-09-05 19:35 ` Simon Wright
2003-09-06 0:25 ` Matthew Heaney
2003-09-06 2:41 ` Steve
2003-09-06 22:01 ` Georg Bauhaus
2003-09-08 9:08 ` Preben Randhol
2003-09-08 9:09 ` Andy
2003-09-09 22:31 ` Nick Roberts
2003-09-10 18:39 ` Mário Amado Alves [this message]
2003-09-23 10:46 ` Jacob Sparre Andersen
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox