From: Jeffrey Carter <spam@spam.com>
Subject: Re: Expectation of Access Value Equality
Date: Fri, 05 Sep 2003 19:32:31 GMT
Date: 2003-09-05T19:32:31+00:00 [thread overview]
Message-ID: <jx56b.408$Yt.242@newsread4.news.pas.earthlink.net> (raw)
In-Reply-To: <bja3fi$glkjh$1@ID-25716.news.uni-berlin.de>
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
next prev parent reply other threads:[~2003-09-05 19:32 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 [this message]
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
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