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.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no 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!news.eternal-september.org!.POSTED!not-for-mail From: Georg Bauhaus Newsgroups: comp.lang.ada Subject: Re: Pointer to instance of indefinite array? Date: Wed, 13 Aug 2014 09:47:40 +0200 Organization: A noiseless patient Spider Message-ID: References: <892c6798-489d-400a-bb9a-7a14605c493f@googlegroups.com> <58a951df-217b-48ee-bd0b-f9953f5b622b@googlegroups.com> <53eaea2e$0$32377$862e30e2@ngroups.net> Reply-To: nonlegitur@futureapps.de Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Wed, 13 Aug 2014 07:47:42 +0000 (UTC) Injection-Info: mx05.eternal-september.org; posting-host="115f9789f889e7926f36e23d6e85c3ce"; logging-data="16069"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19T2lJbvG/Ig3ZQ3JxYrfSe6DtPc/Nx3IA=" User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:24.0) Gecko/20100101 Thunderbird/24.6.0 In-Reply-To: <53eaea2e$0$32377$862e30e2@ngroups.net> Cancel-Lock: sha1:cW618IE6M0DoZ+MvE9U/eCF1bw4= Xref: news.eternal-september.org comp.lang.ada:21710 Date: 2014-08-13T09:47:40+02:00 List-Id: On 13.08.14 06:31, Per Sandberg wrote: > procedure main is > Test_Array : aliased Element_Array (1 .. 20); > begin > Do_Something_With_Array (In_Array => Test_Array'Unrestricted_Access); > -- Use Unrestricted_Access attribute to disable > -- accessibility and aliased view checks > end main; Since 'Unrestricted_Access is not Ada but a GNAT specific pragma, and since it is not strictly needed, I think that standard Ada's own 'Unchecked_Acceess should be enough? procedure Main is Test_Array : aliased Element_Array := (1 .. 20 => (1, 2)); -- declared as an unconstrained type to match the pointer type begin Do_Something_With_Array (In_Array => Test_Array'Unchecked_Access); -- Use Unchecked_Access attribute since passing -- an object that will be inaccessibility at higher levels -- (that of the pointer type) end Main; If there is need to use a pointer at all, e.g. when using GNAT and a really big array and the stack of GNAT's environment task is limited by the operating system, then one may still pass the dereference Test_Array_Ptr.all without any concerns about copying. So Do_Something_With_Array can declare just an array type in its profile, not a pointer. I remember something about the ICC compiler supporting an implementation specific attribute similar to 'Unrestricted_Access. Is there a significant advantage in using 'Unrestricted_Access in user programs, perhaps suppression of more checks so that to something runs a lot faster?