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,29f8f005ed05b2f6 X-Google-Attributes: gid103376,public From: tmoran@bix.com Subject: Re: Thanks Tucker, It works !!! Date: 1998/09/20 Message-ID: <6u1mf4$es8@lotho.delphi.com>#1/1 X-Deja-AN: 392875303 Organization: Delphi Internet Services Newsgroups: comp.lang.ada Date: 1998-09-20T00:00:00+00:00 List-Id: > But I had to do it with an access type per design requirements. The example is a Patriot missile to shoot down a fly. One trusts there's a reason for this complexity in the actual app. > I still don't really understand the aliased, all, and access > keywords working together to allow this sort of C-like pointer Here's one attempt at an explanation: Your Object contains, among other things (eg, abc) a set of 100 pointers to variable sized arrays of integers. These arrays are not created dynamically by 'new' allocators, but are in fact aliases of ordinary arrays declared statically (eg xyz5_array), thus allowing 'back door' access to those arrays and the resulting maintenance, optimization, storage/register placement etc problems of things that can be read or written directly (xyz5_array(3) := 17;) or indirectly (This.XYZ(1).all(3) := 17;). The key word 'aliased' gives warning to the compiler and the maintainer that such shenanigans are going on with xyz5_array. Usually, access types point to things dynamically allocated on the heap with 'new'. But your type "xyz_array_pointer" may in fact point to something allocated on the stack, like xyz5_array, as well. The keyword 'all' tells the compiler and the maintainer this vital fact about xyz_array_pointer. An Ada 83 access type only pointed to heap-allocated objects, so it didn't have 'all' or 'aliased'. Basically, to make your program run in Ada 83, you would have to simplify it by dropping those key words and the line xyz5_array : aliased xyz_array := (1..5 => 0); and changing This.XYZ(1) := xyz5_array'ACCESS; -- address of xyz5_array is assigned to This.XYZ(1) := new xyz_array'((1..5 => 0)); -- an xyz5 array is created Your next question, should you choose to continue this task, will probably be about the error messages you get when forgetting about the lifetime problems of pointers to things that disappear when the stack is popped on return from a subprogram.