comp.lang.ada
 help / color / mirror / Atom feed
From: "ldries46" <bertus.dries@planet.nl>
Subject: Re: Using Access Types for a simple solution
Date: Mon, 25 Jul 2016 17:27:58 +0200
Date: 2016-07-25T17:27:58+02:00	[thread overview]
Message-ID: <57963014$0$20650$e4fe514c@news.kpn.nl> (raw)
In-Reply-To: <579615c5$0$20671$e4fe514c@news.kpn.nl>

Thanks Dimitri,

I did not realise that the aliased not before the array comes but before the 
box.
The suggestion you did I tried before but the code became to complicated to 
be still readable.
May be this not the best way to tackle my problem but is is better readable 
and therefore better maintainable

L. Dries

"ldries46"  schreef in bericht news:579615c5$0$20671$e4fe514c@news.kpn.nl...

Let me first explain the problem. I do have a matrix of records

type Box is record
   ...
   ...
end record

Grid : array( 1 .. N,  1 .. M) of Box;

Now I must do something with a random set out of elements from the matrix. I
would like to create an array of pointers to the elements of the matrix so
that I can use these elements and file the changes directly if the array. So
I created a type:

type Box_Access is access all Box;

and make an array

Box_Array : array(1 .. Q) of Box_Acess;

When try to use that in a simple statement

Box_Array(n) := Grid(n1, n2)'Access;

I get the error (only for this statement): prefix of 'Access attribute must
be aliased.

I tried:

Grid : aliased array( 1 .. N,  1 .. M) of Box;

But that also gives the same error.
I cannot imagine that what I want is not possible in Ada as I can realise it
in C++ so I do miss something.

L. Dries






  parent reply	other threads:[~2016-07-25 15:27 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-07-25 13:35 Using Access Types for a simple solution ldries46
2016-07-25 14:28 ` Dmitry A. Kazakov
2016-07-25 15:27 ` ldries46 [this message]
2016-07-25 21:39   ` rieachus
2016-07-26 18:16 ` Aurele
replies disabled

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