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.9 required=5.0 tests=BAYES_00 autolearn=unavailable autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!news.eternal-september.org!feeder.eternal-september.org!aioe.org!.POSTED!not-for-mail From: "Dmitry A. Kazakov" Newsgroups: comp.lang.ada Subject: Re: Using Access Types for a simple solution Date: Mon, 25 Jul 2016 16:28:46 +0200 Organization: Aioe.org NNTP Server Message-ID: References: <579615c5$0$20671$e4fe514c@news.kpn.nl> NNTP-Posting-Host: xelDFTENDI+dlkJFd2Ot2w.user.gioia.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-Complaints-To: abuse@aioe.org User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.2.0 X-Notice: Filtered by postfilter v. 0.8.2 Xref: news.eternal-september.org comp.lang.ada:31157 Date: 2016-07-25T16:28:46+02:00 List-Id: On 2016-07-25 15:35, ldries46 wrote: > 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. Yes, the error message that tells you: "prefix of 'Access attribute must be aliased". The prefix of 'Access attribute in Grid(n1, n2)'Access is obviously Grid(n1, n2). Aliased array /= array of aliased elements. And you should not use pointers anyway. Do sets of array indices instead. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de