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,5e7d910855b4fd03 X-Google-Attributes: gid103376,public From: dewarr@my-dejanews.com Subject: Re: access type referencing nested array element Date: 1998/09/19 Message-ID: <6u0fmj$hlm$1@nnrp1.dejanews.com>#1/1 X-Deja-AN: 392724994 References: X-Http-Proxy: 1.0 x4.dejanews.com:80 (Squid/1.1.22) for client 205.232.38.14 Organization: Deja News - The Leader in Internet Discussion X-Article-Creation-Date: Sat Sep 19 14:39:15 1998 GMT Newsgroups: comp.lang.ada X-Http-User-Agent: Mozilla/2.02 (OS/2; I) Date: 1998-09-19T00:00:00+00:00 List-Id: In article , stt@houdini.camb.inmet.com (Tucker Taft) wrote: > Technobabble (WishList@2600.com) wrote: > > : Ok, that means that if XYZ is a pointer to array of records, I can simply > : use the pointer with the array index eg. (5) to access the 5th record. > : Now if I want to get the address of the 5th record would this be correct: > > : type xyz is access xyz_rec; > > : XYZ_POINTER := XYZ (5)'access; > > Yes, presuming the array is declared an an array of *aliased* components. > > E.g.: > > type array_of_rec is array(Positive range <>) of aliased xyz_rec; > ^^^^^^^ > This is required if you want to use 'Access. > Indeed, and that helps explain why I advise not using the access attribute AT ALL. Aliasing is in general a bad thing. General pointers were excluded from Ada 83 for very good reasons. They were added in Ada 95 for good, but very narrow reasons (the most convincing argument was the need to be able to statically initialize structures containing pointers) BUT! Once this features is there it is subject to horrible misuse. I find the undisciplined use of pointers and access to be the data analog of gotos. As you all know, I don't have a rule that absolutely forbids gotos, and I do not suggest a rule that absolutely forbids the use of access. Indeed any rule that absolutely forbids the use of any feature in Ada is highly suspect (every feature in Ada was put there for a purpose, if you think a given feature is so useless that it should never be used, you are probably missing something). However, just as we teach students never to use goto, so that they can discover how to properly strucure programs in the usual case, we should teach them never to use 'Access so they can learn how to properly structure their data in the usual case. In particular, the horrible phenomenon of people importing a C style into Ada 95 is something I often see, with the aliased keyword all over the place. Perfectly dreadful coding style! -----== Posted via Deja News, The Leader in Internet Discussion ==----- http://www.dejanews.com/rg_mkgrp.xp Create Your Own Free Member Forum