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.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,ca21162c929cc36f X-Google-Attributes: gid103376,public From: bobduff@world.std.com (Robert A Duff) Subject: Re: Implementing pointers to pointers in Ada Date: 1996/09/10 Message-ID: #1/1 X-Deja-AN: 179797404 references: <512mt3$ret@goodnews.voicenet.com> organization: The World Public Access UNIX, Brookline, MA newsgroups: comp.lang.ada Date: 1996-09-10T00:00:00+00:00 List-Id: In article <512mt3$ret@goodnews.voicenet.com>, John Demby wrote: >Vasilios Tourloupis 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