From: Hyman Rosen <hymie@prolifics.com>
Subject: Re: Ragged Array Proposal
Date: 1999/09/23
Date: 1999-09-23T23:31:54+00:00 [thread overview]
Message-ID: <t7k8ph19um.fsf@calumny.jyacc.com> (raw)
In-Reply-To: 37eaa24b@eeyore.callnetuk.com
"Nick Roberts" <nickroberts@callnetuk.com> writes:
> Try telling a C++ programmer that, in Ada, they have to declare an access
> type, and then repeat the "new String'("xyz")" incantation for every string,
> just to declare an array of strings, and they might be likely to say "Ada?
> No thanks, I'll stick to C++, if you don't mind."
A C programmer, maybe. In C++, if you want to initialize one of the
STL containers with constant data, you pretty much have to make copies
of things.
In C, we often do
char *fruits[] = { "apple", "orange", "pear" };
The compiler does a bunch of accounting for us to make this possible.
What we have really written above is the following:
static char unique_apple[6] { 'a', 'p', 'p', 'l', 'e', 0 };
static char unique_orange[7] = { 'o', 'r', 'a', 'n', 'g', 'e', 0 };
static char unique_pear[5] = { 'p', 'e', 'a', 'r', 0 };
char *fruits[3] = { &unique_apple[0], &unique_orange[0], &unique_pear[0] };
Is it possible to do something similar in Ada?
Something like (forgive my fractured pseudo-Ada syntax) -
apple: aliased String(5) := "apple";
orange: aliased String(6) := "orange";
pear: aliased String(4) := "pear";
type StringPtr is access String(<>);
fruits: StringPtr[1..3] := (apple'access, orange'access, pear'access);
next prev parent reply other threads:[~1999-09-23 0:00 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <37e7c08e@eeyore.callnetuk.com>
1999-09-22 0:00 ` Ragged Array Proposal Ted Dennison
1999-09-22 0:00 ` Ray Blaak
1999-09-23 0:00 ` Ted Dennison
1999-09-23 0:00 ` Tucker Taft
1999-09-23 0:00 ` Nick Roberts
1999-09-23 0:00 ` Hyman Rosen [this message]
1999-09-24 0:00 ` Nick Roberts
1999-09-24 0:00 ` Hyman Rosen
1999-09-25 0:00 ` Robert Dewar
1999-09-27 0:00 ` Hyman Rosen
1999-09-27 0:00 ` Brian Rogoff
1999-09-28 0:00 ` Robert Dewar
1999-09-24 0:00 ` Robert Dewar
1999-09-24 0:00 ` Wes Groleau
1999-09-25 0:00 ` Robert Dewar
1999-09-25 0:00 ` Robert Dewar
1999-09-24 0:00 ` Ted Dennison
1999-09-24 0:00 ` Nick Roberts
1999-09-24 0:00 ` Robert Dewar
1999-09-24 0:00 ` Robert Dewar
1999-09-23 0:00 ` Robert I. Eachus
1999-09-24 0:00 ` Nick Roberts
1999-09-25 0:00 ` Robert Dewar
1999-09-25 0:00 ` Robert Dewar
1999-09-25 0:00 ` Robert Dewar
1999-09-27 0:00 ` Ted Dennison
1999-09-27 0:00 ` Pascal Obry
1999-09-28 0:00 ` Ted Dennison
1999-09-28 0:00 ` Robert Dewar
1999-09-29 0:00 ` Geoff Bull
1999-09-28 0:00 ` Robert Dewar
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox