comp.lang.ada
 help / color / mirror / Atom feed
* Question[s] about aliased extended return.
@ 2012-11-02 15:55 Shark8
  2012-11-09  0:43 ` Randy Brukardt
  0 siblings, 1 reply; 16+ messages in thread
From: Shark8 @ 2012-11-02 15:55 UTC (permalink / raw)


The syntax for the extended return given in the RM [ http://www.ada-auth.org/standards/12rm/html/RM-6-5.html ] allows for the usage of the keyword ALIASED, with the restriction of "if the keyword aliased is present in an extended_return_object_declaration, the type of the extended return object shall be immutably limited."

The 2012 rationale entry regarding the extended return [ http://www.ada-auth.org/standards/12rat/html/Rat12-4-6.html ] says of immutably limited objects:
* it is an explicitly limited record type,
* it is a task type, protected type or synchronized interface,
* it is a non-formal limited private type that is tagged or has an access discriminant with a default expression, [or]
* it is derived from an immutably limited type.

(1) Doesn't this reduce the usefulness of the extended return?

There are a couple of times building the OpenGL binding where I would have liked to do something like:
Function some_vector( [params] ) Return Vector_of_points is
begin
  Return Result : access 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 allowed.
(2) Is there a reason this is not allowed? (Thick/thin 'pointer' differences?)

Lastly, the GNAT compiler seems to reject the following, even though the rationale says a "explicitly limited record type" qualifies as immutably limited:
    Type LR is limited record
	Data : Character:= 'X';
    End record;
    
    Function Get_LR Return LR is
    begin
	Return Result : aliased LR do
	    null;
	end return;
    end Get_LR;
(3) Is this a bug, or am I just misreading everything?



^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2012-11-16  9:33 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-11-02 15:55 Question[s] about aliased extended return Shark8
2012-11-09  0:43 ` Randy Brukardt
2012-11-09  3:40   ` Yannick Duchêne (Hibou57)
2012-11-10  7:34     ` Randy Brukardt
2012-11-09 19:42   ` Shark8
2012-11-09 20:53     ` sbelmont700
2012-11-09 21:44       ` Yannick Duchêne (Hibou57)
2012-11-09 22:04         ` sbelmont700
2012-11-09 22:56           ` Shark8
2012-11-09 22:54         ` Shark8
2012-11-10  7:27           ` Randy Brukardt
2012-11-10 16:08             ` Shark8
2012-11-10  1:08     ` Jeffrey Carter
2012-11-10  1:52       ` Shark8
2012-11-10  2:17         ` Yannick Duchêne (Hibou57)
2012-11-10 10:59         ` Bill Findlay

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox