From: Georg Bauhaus <bauhaus@futureapps.invalid>
Subject: Re: Pointer to instance of indefinite array?
Date: Wed, 13 Aug 2014 09:47:40 +0200
Date: 2014-08-13T09:47:40+02:00 [thread overview]
Message-ID: <lsf56u$fm5$1@dont-email.me> (raw)
In-Reply-To: <53eaea2e$0$32377$862e30e2@ngroups.net>
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?
next prev parent reply other threads:[~2014-08-13 7:47 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-08-13 2:07 Pointer to instance of indefinite array? NiGHTS
2014-08-13 2:09 ` Jeffrey Carter
2014-08-13 2:29 ` Shark8
2014-08-13 3:06 ` NiGHTS
2014-08-13 4:28 ` Jeffrey Carter
2014-08-13 16:06 ` NiGHTS
2014-08-13 17:43 ` Jeffrey Carter
2014-08-13 17:58 ` Shark8
2014-08-13 18:36 ` Dmitry A. Kazakov
2014-08-13 4:31 ` Per Sandberg
2014-08-13 7:47 ` Georg Bauhaus [this message]
2014-08-13 8:05 ` Egil H H
2014-08-13 15:32 ` Adam Beneschan
2014-08-14 8:03 ` Georg Bauhaus
2014-08-13 18:17 ` Niklas Holsti
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox