From: bobduff@world.std.com (Robert A Duff)
Subject: Re: Implementing pointers to pointers in Ada
Date: 1996/09/10
Date: 1996-09-10T00:00:00+00:00 [thread overview]
Message-ID: <DxJBF3.1y2@world.std.com> (raw)
In-Reply-To: 512mt3$ret@goodnews.voicenet.com
In article <512mt3$ret@goodnews.voicenet.com>,
John Demby <jdemby@voicenet.com> wrote:
>Vasilios Tourloupis <vasilios@insect.sd.monash.edu.au> wrote:
>
>>Dear Ada users,
>
>>As the title suggests, how would I go about implementing pointers to
>>pointers in Ada?
>>For example, I have declared the following variable in C:
>> unsigned **a;
>>How would this be expressed in Ada terms?
>
>in general :
>
>type unsigned is blah;
>type unsigned_star is access unsigned;
>type unsigned_star_star is access unsigned_star;
Several people have suggested this, but I think it's highly unlikely to
be the answer the original poster is looking for. In C, "unsigned **a"
means you're dealing with a pointer-to-pointer-to-unsigned, or a
pointer-to-array-of-unsigned, or an array-of-pointers-to-unsigned. We
can't tell which it is, without knowing whether the code does a++ or
(*a)++ or whatever. Or without knowing where the value of a comes from.
In any case, the "equivalent" Ada probably involves an array type, since
Ada has two separate features -- access types and arrays -- where C has
a single feature (pointers, which can point at single objects, or can
point at the first element of an array, or the middle of an array).
(Well, that's an oversimplification -- in C, arrays and pointers are not
*quite* the same thing, but they are in many circumstances, which is
quite confusing.)
Alternatively, maybe the "unsigned **a" is being used as a parameter.
If so, then the equivalent Ada probably involves an in-out parameter.
Perhaps the original poster can post more context, so we can see what
SORT of C pointers are being used, and advise whether they should
translate into arrays or in-out parameters, or whatever.
In Ada, I think I use access-to-access types approximately once per
decade, so I really don't think that's likely to be the right answer.
- Bob
prev parent reply other threads:[~1996-09-10 0:00 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
1996-09-09 0:00 Implementing pointers to pointers in Ada Vasilios Tourloupis
1996-09-09 0:00 ` Norman H. Cohen
1996-09-09 0:00 ` Samuel Tardieu
1996-09-09 0:00 ` Mark A Biggar
1996-09-09 0:00 ` Jonas Nygren
1996-09-09 0:00 ` John Herro
1996-09-10 0:00 ` David Shochat
1996-09-11 0:00 ` Larry Kilgallen
1996-09-12 0:00 ` Dr. John B. Matthews
1996-09-13 0:00 ` Better MacOS Handles through Ada (was: Implementing Pointers to Pointe Larry Kilgallen
1996-09-14 0:00 ` Dr. John B. Matthews
1996-09-15 0:00 ` GUI Generators and Class Libraries (was: Better MacOS Handles Larry Kilgallen
1996-09-15 0:00 ` jim hopper
1996-09-16 0:00 ` Larry Kilgallen
1996-09-17 0:00 ` GUI Generators and Class Libraries (wa David Kristola
1996-09-17 0:00 ` GUI Generators and Class Libraries Dr. John B. Matthews
1996-09-10 0:00 ` Implementing pointers to pointers in Ada John Demby
1996-09-10 0:00 ` Robert A Duff [this message]
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox