comp.lang.ada
 help / color / mirror / Atom feed
From: jesup@steinmetz.steinmetz.UUCP (Randell Jesup)
Subject: Re: A Problem With Access Types
Date: Sun, 12-Apr-87 02:54:14 EST	[thread overview]
Date: Sun Apr 12 02:54:14 1987
Message-ID: <1426@steinmetz.steinmetz.UUCP> (raw)
In-Reply-To: 8704081652.AA09954@skl-crc.ARPA

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

  reply	other threads:[~1987-04-12  7:54 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1987-04-08 16:52 A Problem With Access Types bradford
1987-04-12  7:54 ` Randell Jesup [this message]
     [not found] <9954@skl-crc.ARPA>
1987-04-10 19:42 ` callen
1987-04-12 16:44   ` dik
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox