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=0.7 required=5.0 tests=BAYES_00,INVALID_DATE, MSGID_SHORT,REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!rutgers!clyde!cbatt!ihnp4!chinet!steinmetz!jesup From: jesup@steinmetz.steinmetz.UUCP (Randell Jesup) Newsgroups: comp.lang.ada Subject: Re: A Problem With Access Types Message-ID: <1426@steinmetz.steinmetz.UUCP> Date: Sun, 12-Apr-87 02:54:14 EST Article-I.D.: steinmet.1426 Posted: Sun Apr 12 02:54:14 1987 Date-Received: Sat, 18-Apr-87 19:12:32 EST References: <8704081652.AA09954@skl-crc.ARPA> Reply-To: jesup@kbsvax.steinmetz.UUCP (Randell Jesup) Distribution: na Organization: General Electric CRD, Schenectady, NY List-Id: In article <8704081652.AA09954@skl-crc.ARPA> bradford@SKL-CRC.ARPA (Bob Bradford) writes: >I am writing a program which manipulates a large, complex data structure. >The data structure consists of many embedded records and arrays >of records. I wish to have a procedure update a particular record within ... > type A_REC is > record > ... > end; > > type A_ACCESS is access A_REC; > > A : A_REC; > A_A : A_ACCESS; > > begin > ... > A_A := A; -- Also tried A_A := A_ACCESS(A); > UPDATE(A_A); > ... > end; ... [Vax ada doesn't like it, nor does the LRM] >Bob Bradford They doen't like for one reason: A (which is of type A_REC) is a declared object, not an allocated one. An access variable cannot refer to anything that was not created by an allocator, and therefor cannot be set to point to your static variable (A). The way to make it work is to make something like this: type A_REC is record ... end record; type A_ACCESS is access A_REC; A : A_ACCESS; -- Note! A_A : A_ACCESS; begin ... A := new A_REC... ... A_A := A; UPDATE(A_A); ... end Randell Jesup jesup@steinmetz.uucp jesup@ge-crd.arpa