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=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,39c061fa6e3ec349 X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII Path: g2news2.google.com!postnews.google.com!s33g2000prg.googlegroups.com!not-for-mail From: Adam Beneschan Newsgroups: comp.lang.ada Subject: Re: acceess problem Date: Tue, 26 Jul 2011 10:43:22 -0700 (PDT) Organization: http://groups.google.com Message-ID: <980bda39-954a-4b4e-8b7d-fb9597f808c0@s33g2000prg.googlegroups.com> References: <4e2c416b$0$2574$703f8584@news.kpn.nl> <4e2d13bc$0$2576$703f8584@news.kpn.nl> <8727ccd3-d7e9-4d41-b55c-9c3d4fba1a78@df3g2000vbb.googlegroups.com> NNTP-Posting-Host: 66.126.103.122 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: posting.google.com 1311702202 12465 127.0.0.1 (26 Jul 2011 17:43:22 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Tue, 26 Jul 2011 17:43:22 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: s33g2000prg.googlegroups.com; posting-host=66.126.103.122; posting-account=duW0ogkAAABjRdnxgLGXDfna0Gc6XqmQ User-Agent: G2/1.0 X-Google-Web-Client: true X-Google-Header-Order: ARLUEHNKC X-HTTP-UserAgent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0; WOW64; Trident/4.0; SLCC1; .NET CLR 2.0.50727; Media Center PC 5.0; .NET CLR 3.5.21022; .NET CLR 3.5.30729; .NET CLR 3.0.30618; .NET4.0C),gzip(gfe) Xref: g2news2.google.com comp.lang.ada:21339 Date: 2011-07-26T10:43:22-07:00 List-Id: On Jul 26, 8:57=A0am, Gautier write-only wrote: > On 25 juil, 10:27, Simon Wright wrote: > > > Replace 'Access with 'Unchecked_Access or, if that doesn't work, with > > the (GNAT-special) 'Unrestricted_Access. > > Unless 'Unrestricted_Access has been inbetween added to the language, > there is a way to have it in a pure Ada form: > > =A0 function Cvt is new > Ada.Unchecked_Conversion(System.Address,DoublePtr); > =A0 -- This method is functionally identical as GNAT's > Unrestricted_Access > =A0 -- but has no type safety (cf GNAT Docs) > =A0 pragma No_Strict_Aliasing(DoublePtr); -- recommended by GNAT 2005 > > =A0 procedure Vertex (v: Double_vector_3D) is > =A0 begin > =A0 =A0 Vertex3dv(Cvt(v(0)'Address)); > =A0 end Vertex; > > ^this is an excerpt from an existing GL binding (why reinvent it?)...http= ://globe3d.svn.sourceforge.net/viewvc/globe3d/bindings/gl.adb?rev... Although I don't like this approach, if you're going to convert an Address to an access object, surely it's better to use System.Address_To_Access_Conversions, which is designed for this sort of conversion, than to use Unchecked_Conversion, which assumes that a System.Address and the access object you're converting to have the same format, which isn't always the case. There's no point in using "pure Ada" if it results in code that compiles on another system but doesn't work properly. -- Adam