comp.lang.ada
 help / color / mirror / Atom feed
* A Problem With Access Types
@ 1987-04-08 16:52 bradford
  1987-04-12  7:54 ` Randell Jesup
  0 siblings, 1 reply; 4+ messages in thread
From: bradford @ 1987-04-08 16:52 UTC (permalink / raw)




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
this structure, and what I tried to do originally was to simply create
an access type variable for the record type and then have this access
variable refer to the record and then pass the access variable to the
procedure. The following segment represents what I tried to do:

     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;

Ada (VAX Ada 1.3) won't let me do this, and after re-reading the LRM,
it seems that this is consistent with the LRM. So I have to do it some
other way. Some options are: 

       1) Pass the whole structure and require the called procedure to
          know the structure (I really don't like this option).

       2) Copy the appropriate record, pass the copy as  an inout parameter,
          and update the record from the returned copy.

       3) Give up and quit (but that means I won't get paid and I really
          like getting paid).

Option 2 is workable for the problem I described above, but having access
types would be easier for a similar, related problem (which I won't go into
here). Can anyone supply another altrernative, or perhaps a way of using access
types like I wanted to originally. I would be most grateful.


Bob Bradford

^ permalink raw reply	[flat|nested] 4+ messages in thread
[parent not found: <9954@skl-crc.ARPA>]

end of thread, other threads:[~1987-04-12 16:44 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1987-04-08 16:52 A Problem With Access Types bradford
1987-04-12  7:54 ` Randell Jesup
     [not found] <9954@skl-crc.ARPA>
1987-04-10 19:42 ` callen
1987-04-12 16:44   ` dik

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