Version 1.3 of ais/ai-00360.txt

Unformatted version of ais/ai-00360.txt version 1.3
Other versions for file ais/ai-00360.txt

!standard 07.06(09)          03-11-19 AI95-00360/03
!standard D.07(04)
!class binding interpretation 03-10-08
!status work item 03-10-08
!status received 03-10-08
!priority Medium
!difficulty Easy
!subject Types that need finalization
!summary
Some types are defined to need finalization. The restriction No_Nested_Finalization is defined in terms of types that need finalization. A of language-defined types are defined to need finalization.
!question
The restriction No_Nested_Finalization is expressed in terms of controlled types. However, there are a number of language-defined types which, while not visibly controlled, might well be implemented using controlled types by some implementations. Are such types affected by No_Nested_Finalization? (Yes, see list in the !wording section.) Furthermore, the definition of No_Nested_Finalization doesn't take into account access discriminants, which can cause nested finalization to happen. Is this intended? (No.)
!recommendation
See !summary
!wording
Insert after 7.6(9):
A type is said to need finalization if:
o it is a controlled type, a task type or a protected type; or
o it has subcomponents that need finalization; or
o it has an access discriminant whose designated subtype needs finalization; or
o it is one of a number of language-defined types that are explicitly defined
to need finalization.
Insert after A.4.5(72):
The type Unbounded_String needs finalization.
Insert after A.8.1(16):
The type File_Type needs finalization in every instantiation of Sequential_IO.
Insert after A.8.4(19):
The type File_Type needs finalization in every instantiation of Direct_IO.
Insert after A.10.1(85):
The type File_Type needs finalization.
Insert after A.12.1(27):
The type File_Type needs finalization.
Replace D.7(4) by:
No_Nested_Finalization
Objects of a type that needs finalization and access types that designate a type that needs finalization shall be declared only at library level.
Add in the Static Semantics of D.15 (AI 297):
The type Timing_Event needs finalization.
Add in the Static Semantics of D.14 (AI 207):
The type Timer needs finalization.
Add in the Static Semantics of AI 354:
The type Group_Timer needs finalization.
!discussion
Note that the current wording of D.7(4) doesn't take into account the case of access discriminants designating controlled objects. For example:
with Ada.Finalization.Controlled; package P is type T1 is new Ada.Finalization.Controlled with null record; type T2 (D : access T1) is limited null record; end P;
with P; procedure Q is pragma Restrictions (No_Nested_Finalization); X : P.T2 (D => new P.T1); -- Legal? (No.) begin null; end Q;
In this example the finalization of X causes the finalization of X.D, which is effectively a nested finalization. However, this case is not forbidden by the existing wording of D.7(4).
--!corrigendum
!example
!ACATS test
!appendix

From: Tucker Taft
Sent: Wednesday, October 8, 2003  10:26 AM

"Quasi-controlled" makes me feel queasy.

How about just define the term "needs finalization"?  I think that
will be easier to stomach ;-).

****************************************************************

From: Pascal Leroy
Sent: Wednesday, October 8, 2003  2:49 PM

> "Quasi-controlled" makes me feel queasy.

I knew you wouldn't like it ;-)

> How about just define the term "needs finalization"?  I think that
> will be easier to stomach ;-).

Well, it's not exactly "needs finalization", because protected types and
tasks need some kind of finalization, and they are not covered by
restriction No_Nested_Finalization.  What this restriction covers is
really "controlled types and their buddies".  Therefore I believe that
the new term has to say "controlled" somewhere.  However, I would
welcome a better name...

****************************************************************

From: Tucker Taft
Sent: Wednesday, October 8, 2003  3:52 PM

No, there you are wrong.  No_Nested_Finalization *does* cover
Task and Protected types.  We made that change a while ago.
So I think "needs finalization" is just about right.

****************************************************************

From: Jean-Pierre Rosen
Sent: Thursday, October 9, 2003  1:58 AM

What about "potentially controlled" ? Reminds of "potentially blocking",
and I think it grasps the idea, at least for things like Unbounded_String.
The standard does not *require* Unbounded_String to be controlled, but
we know damn well that they might be...

****************************************************************

From: Tucker Taft
Sent: Thursday, October 9, 2003  10:24 AM

As I pointed out, in Ada 2000, No_Nested_Finalization includes
no nested tasks and protected types as well.  It sounds
like you folks are using outdated manuals.  For shame!

****************************************************************

From: Pascal Leroy
Sent: Friday, October 10, 2003  3:44 AM

Yes, sorry, I was reading the original, obsolete RM, not the new fancy
one updated by TC1.

****************************************************************

Questions? Ask the ACAA Technical Agent