comp.lang.ada
 help / color / mirror / Atom feed
From: Jere <jhb.chat@gmail.com>
Subject: Re: Ada Alternatives to Unrestricted_Access
Date: Thu, 8 Mar 2018 16:41:47 -0800 (PST)
Date: 2018-03-08T16:41:47-08:00	[thread overview]
Message-ID: <47a66da9-1862-459c-b236-562417b31f0d@googlegroups.com> (raw)
In-Reply-To: <79006263-c9a7-497a-af50-de9e5045af07@googlegroups.com>

On Wednesday, March 7, 2018 at 10:18:47 PM UTC-5, gautier wrote:
> I had the same problem for GL[U[T]] bindings (work on both GNAT and ObjectAda, and perhaps other Ada systems) [1]. A quick search with AZip (shameless plug :-) [2] leads to 
>   package A2A_double is new System.Address_To_Access_Conversions(Double);
> ...
>   procedure Vertex (v: Double_Vector_3D) is
>   begin
>     Vertex3dv(A2A_double.To_Pointer(v(0)'Address));
>     -- This method is functionally identical
>     -- to using GNAT's 'Unrestricted_Access
>   end Vertex;
> 
> Other places use an Unchecked_Conversion.
> The GNAT doc says:
> "The Unrestricted_Access attribute is similar to Access except that all accessibility and aliased view checks are omitted. This is a user-beware attribute. It is similar to Address, for which it is a desirable replacement where the value desired is an access type. In other words, its effect is identical to first applying the Address attribute and then doing an unchecked conversion to a desired access type."
> 
> ___
> 
> [1] https://globe3d.sourceforge.io/
> [2] https://azip.sourceforge.io/

Yep, that's basically the same conclusion I came to.  My doubts center
around whether it is legit in portable Ada to do so to bypass the "in"
mode.  I don't know if the language allows for a compiler to use
different representations for a constant variable and a mutable variable.
If so, what I am doing might possibly be erroneous behavior.  It would
work in GNAT based on the section you quoted, but I was curious if
it would run afoul in other compilers possibly.

  reply	other threads:[~2018-03-09  0:41 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-07 20:11 Ada Alternatives to Unrestricted_Access Jere
2018-03-07 20:38 ` Dmitry A. Kazakov
2018-03-07 22:29   ` Jere
2018-03-08  8:27     ` Dmitry A. Kazakov
2018-03-09  0:43       ` Jere
2018-03-09  0:52         ` Jere
2018-03-09  8:28           ` Dmitry A. Kazakov
2018-03-11  0:31             ` Jere
2018-03-08  3:18 ` gautier_niouzes
2018-03-09  0:41   ` Jere [this message]
2018-03-08 17:51 ` Jeffrey R. Carter
2018-03-09  0:36   ` Jere
2018-03-09 16:46     ` Jeffrey R. Carter
2018-03-11  0:38       ` Jere
2018-03-11  9:57         ` Jeffrey R. Carter
2018-03-11 10:44           ` Dmitry A. Kazakov
2018-03-11 14:31           ` Jere
2018-03-11 15:49             ` Jeffrey R. Carter
2018-03-11 17:33               ` Jere
2018-03-11 18:12                 ` Jeffrey R. Carter
2018-03-11 19:53                   ` Jere
2018-03-12 16:28                     ` Jeffrey R. Carter
2018-03-11 18:27                 ` Niklas Holsti
2018-03-11 20:07                   ` Jere
2018-03-12 23:35                     ` Randy Brukardt
2018-03-12 23:30         ` Randy Brukardt
2018-03-13  7:46           ` 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