!standard 07.06 (11) 97-11-14 AI95-00182/03 !class binding interpretation 97-03-19 !status WG9 Approved 97-11-14 !status ARG Approved (subject to editorial review) 10-0-0 97-04-11 !status work item 97-03-19 !status received 97-03-19 !priority High !difficulty Easy !subject Extension aggregates with controlled subcomponents !summary 97-05-08 For an extension_aggregate whose ancestor_part is a subtype_mark, for each controlled subcomponent of the ancestor part, either Initialize is called, or the default initial value is assigned, as appropriate. 7.6.1(13) is modified so that an anonymous object is not finalized until after it is no longer accessible via any name. !question 97-05-08 Question 1: 7.6(11) says: "For an extension_aggregate whose ancestor_part is a subtype_mark, Initialize is called on all controlled subcomponents of the ancestor part". This seems inappropriate in the case of a controlled subcomponent for which a default initial value has been given. What is the intent? Question 2: 7.6.1(13) says: "The anonymous objects created by function calls ... are finalized no later than the end of the innermost enclosing declarative_item or statement." This rule permits a reference to a finalized object in the case where the function call is used as a name in an object renaming declaration: X : Some_Controlled_Type renames Some_Function_Call; and similarly when the function call is used as an actual parameter for a generic formal in out parameter, or when a component of the object returned by the function call is renamed. !recommendation 97-05-08 (See Summary.) !wording 97-03-19 (See Summary.) !discussion 97-05-08 Question 1: The intent is that Initialize should not be called when there is an initial value to be assigned. Question 2: The intent is that such renamed objects should not be finalized until they are no longer "in use". !appendix 97-03-19 !section 7.6(11) !subject Extension aggregates with controlled subcomponents !reference RM95 7.6(11) !from Pascal Leroy 97-03-10 !reference 97-15727.a Pascal Leroy 97-3-10>> !discussion The referenced paragraph states that: "For an extension_aggregate whose ancestor_part is a subtype_mark, Initialize is called on all controlled subcomponents of the ancestor part". This seems inappropriate in the case of a controlled subcomponent for which a default initial value has been given. Consider the following example: type T1 is new Ada.Finalization.Controlled with null record; X : T1; type T2 is new Ada.Finalization.Controlled with record F : T1 := X; end record; type T3 is new T2 with null record; Y : T3 := (T2 with null record); RM95 7.6(11) seems to say that Initialize is called on component F of the extension aggregate, but it would be more sensible to assign to F the initial value X. That would be consistent with the treatment of objects created by object_declarations, as specified in RM95 7.6(10). **************************************************************** !section 7.6.1(13) !subject Renaming a controlled object returned by a function !reference RM95 7.6.1(13) !from Pascal Leroy 97-03-10 !reference 97-15727.b Pascal Leroy 97-3-10>> !discussion The referenced paragraph states that: "The anonymous objects created by function calls ... are finalized no later than the end of the innermost enclosing declarative_item or statement." This rule permits a reference to a finalized object in the case where the function call is used as a name in an object renaming declaration: X : Some_Controlled_Type renames Some_Function_Call; and similarly when the function call is used as an actual parameter for a generic formal in out parameter, or when a component of the object returned by the function call is renamed. ****************************************************************