CVS difference for ais/ai-00083.txt

Differences between 1.5 and version 1.6
Log of other versions for file ais/ai-00083.txt

--- ais/ai-00083.txt	1999/10/08 23:41:05	1.5
+++ ais/ai-00083.txt	1999/11/19 00:43:43	1.6
@@ -1,4 +1,4 @@
-!standard 07.06    (21)                               99-10-07  AI95-00083/04
+!standard 07.06    (21)                               99-11-18  AI95-00083/05
 !standard 07.06.01 (20)
 !class binding interpretation 95-07-27
 !status Corrigendum 2000 99-07-28
@@ -11,8 +11,8 @@
 
 !summary
 
-When an object of a controlled type is created and explicitly
-initialized with an aggregate, the aggregate is built "in place";
+When an (extension) aggregate of a controlled type is assigned other
+than an assignment or return statement, the aggregate is built "in place";
 Finalize and Adjust are not called on the object as a whole.
 
 !question
@@ -23,12 +23,14 @@
 
 !recommendation
 
-When an object of a controlled type is created and explicitly
-initialized with an aggregate, the implementation must not create a
-separate anonymous object for the aggregate; it must create the value of
-the aggregate directly in the newly-created object.  Thus, there is no
-assignment from the anonymous object to the newly-created object, so the
-Finalize and Adjust that would be done for that assignment are not done.
+When an aggregate of a controlled type is created and immediately assigned
+into an object other than in an assignment or return statement (that is in
+an initial expression, subaggregate, formal parameter, generic IN parameter,
+or allocator), the implementation must not create a separate anonymous
+object for the aggregate; it must create the value of the aggregate directly
+in the target object. Thus, there is no assignment from the anonymous object
+to the target object, so the Finalize and Adjust that would be done for that
+assignment are not done.
 
 !wording
 
@@ -89,6 +91,24 @@
 
 The aggregate must be built directly in the newly-created heap object.
 
+Similarly, if we have
+    function Is_Null (Value : in Dyn_String) return Boolean;
+
+then the aggregate actual parameter in the call
+
+    if Is_Null ((Ada.Finalization.Controlled with ...)) then
+
+is built directly in a temporary object, and Adjust is not called on the object
+as a whole.
+
+We except assignment and return statements from this requirement as there is
+no compelling reason to burden implementations with this requirement in those
+cases.
+
+Note that all aggregates of a controlled type are extension aggregates:
+Controlled and Limited_Controlled are private, so it is not possible to
+create a normal record aggregate for such a type.
+
 !corrigendum 7.06.01(20)
 
 @dinsa
@@ -165,6 +185,55 @@
 
 ****************************************************************
 
+!section 7.6(21)
+!subject Aggregates of a controlled type
+!section 7.6
+!reference AI95-00083/02
+!reference RM95-7.6(21)
+!from Gary Dismukes 97-07-11
+!reference 1997-15794.a Gary Dismukes 1997-11-8>>
+!discussion
+
+AI-83 requires that a controlled object initialized by an
+aggregate be built in place, without the use of the canonical
+temporary object.  It seems that this requirement should also
+exist for cases involving controlled components with default
+initialization given by an aggregate, but it's not clear from
+the wording of the AI whether it's intended to apply to such
+cases.
+
+For example, building on the example in the AI:
+
+    type Dyn_String is private;
+    Null_String : constant Dyn_String;
+ ...
+ private
+    type Dyn_String is new Ada.Finalization.Controlled
+      with record
+        ...
+      end record;
+    procedure Finalize(X : in out Dyn_String);
+    procedure Adjust(X : in out Dyn_String);
+
+    type Rec_with_String is
+      record
+        Str : Dyn_String := (Ada.Finalization.Controlled with ...);
+      end record;
+
+    RS : Rec_with_String;
+
+Is it intended that the component RS.Str be initialized in place,
+without the use of a separate temporary object to hold the value
+of the aggregate?  The fact that the summary says "explicitly
+initialized" makes it unclear to me whether the AI is intended
+to apply to this case (although the end of the !recommendation
+does state that the interpretation applies to all object creations).
+The question is whether the component's default initialization
+is properly considered to be an "explicit initialization" for
+purposes of this AI.
+
+****************************************************************
+
 From: Randy Brukardt
 Sent: October 7, 1999
 
@@ -189,4 +258,28 @@
 Controlled itself is private, so it is not possible to create a normal
 aggregate for such a type.
 
+------
+
+The WG9 concerns with this AI were also discussed at the recent ARG meeting.
+The following example was given:
+
+   type T is new TP with ...
+   X : T := T'(TP with ...);
+
+If TP is controlled, then TP initialize gets called, but the finalize is T.
+
+After discussion, it was determined that is in fact the expected behavior in
+Ada 95, and indeed this AI doesn't change that fact. There are three ways to
+create a controlled object in Ada 95: via Initialize (a default-initialized
+object); Adjust (an explicitly initialized object); and via an aggregate
+(for which neither Initialize nor Adjust is called).
+
+It was pointed out that it is important that an overridding Finalize (for
+instance) call the Finalize routine of its parent. If T's Finalize calls
+TP Finalize in the above example, there probably aren't any problems.
+
+Tucker volunteered to write an LSN document describing the Ada 95 controlled
+type model, including the various surprises which are possible.
+
 ****************************************************************
+

Questions? Ask the ACAA Technical Agent