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.9 required=5.0 tests=BAYES_00,FORGED_GMAIL_RCVD, FREEMAIL_FROM autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: a07f3367d7,e51f94f876618e37 X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII-7-bit Received: by 10.66.89.164 with SMTP id bp4mr4697580pab.14.1352490157393; Fri, 09 Nov 2012 11:42:37 -0800 (PST) Received: by 10.68.229.231 with SMTP id st7mr2414300pbc.2.1352490157374; Fri, 09 Nov 2012 11:42:37 -0800 (PST) Path: s9ni1660pbb.0!nntp.google.com!kt20no39768831pbb.1!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Fri, 9 Nov 2012 11:42:37 -0800 (PST) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=69.20.190.126; posting-account=lJ3JNwoAAAAQfH3VV9vttJLkThaxtTfC NNTP-Posting-Host: 69.20.190.126 References: <9bbd99bd-f953-434d-b3c8-6e8a6d5c7dfd@googlegroups.com> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: Subject: Re: Question[s] about aliased extended return. From: Shark8 Injection-Date: Fri, 09 Nov 2012 19:42:37 +0000 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Date: 2012-11-09T11:42:37-08:00 List-Id: On Thursday, November 8, 2012 5:43:18 PM UTC-7, Randy Brukardt wrote: > "Shark8" wrote in message=20 >=20 > > There are a couple of times building the OpenGL binding where I would h= ave=20 > > liked to do something like: > > Function some_vector( [params] ) Return Vector_of_points is > > begin > > Return Result : ALIASED Vector_of_points( 1..size_from_params ) do > > glFunctionPopulatingVector( glEnum_from_params, Result'access ) > > end return; > >end some_vector; > >in order to populate the vector with the requisite data, but this is not= =20 > >allowed. >=20 > I presume you meant "aliased" rather than "access" in the return statemen= t=20 > here. Yes. >=20 > IMHO, you get what you deserve when you use access parameters rather than= =20 > "in out" parameters. There is no good reason to use an access parameter i= n a=20 > routine like Populating_Vector (at least in the Ada part - you might have= to=20 > do all kinds of nasty things in the thin interface). Ah that's kinda the point, this is WRT the implementation part [of my OpenG= L binding] and therefore the interface between the thin/raw-imports and the= more useful/friendly Ada world. (By Vector I mean something like "Array (P= ositive Range <>) of Float" [or whatever], not the Containers's Vector.) As it is I have to do something like: Function Get_Elements(Item:Texture_Coordinate_Generation) Return Positi= ve is begin case Item is when TEXTURE_GEN_MODE =3D> Return 1; when OBJECT_PLANE | EYE_PLANE =3D> Return 4; end case; end Get_Elements; Function GetTexGen ( coord : Texture_Coordinate_Type; pname : Texture_Coordinate_Generation) Return Double_Vector_Type is begin Return Result : Double_Vector_Type(1..Get_Elements( pname )) do glGetTexGendv( coord =3D> Convert(coord), pname =3D> Convert(pname), params =3D> To_Pointer( Result'Address ) ); End Return; end GetTexGen; Where Convert is Unchecked_Conversion to GLEnum, and To_Pointer is Address/= access conversion. {Aliased return statements would then allow me to be rid= of a whole dependency... oh well.} >=20 > > Lastly, the GNAT compiler seems to reject the following, [..]=20 > >(3) Is this a bug, or am I just misreading everything? >=20 > Looks like a bug to me. Thank you, good to know.