Version 1.1 of acs/ac-00207.txt

Unformatted version of acs/ac-00207.txt version 1.1
Other versions for file acs/ac-00207.txt

!standard A.18.3(90/2)          11-01-26 AC95-00207/01
!class confirmation 11-01-26
!status received no action 11-01-26
!status received 10-10-28
!subject Preelaborable initialization
!summary
!appendix

!reference Ada 2005 RM10.2.1(11.4/2)
!from Thomas Quinot 10-10-28
!keywords preelaborable initalization, controlled types, overriding Initialize
!discussion

10.2.1(11.4/2) refers to controlled types with an overriding
Initialize procedure (and 10.2.1(11.4/3) resulting from AI05-028
has similar language about "an Initialize procedure
that is not a null procedure").

This seems far to broard; the intent of the clause is certainly to apply
only to an Initialize procedure that would override *the*
predefined Initialize primitive declared for types
Ada.Finalization.[Limited_]Controlled (or that procedure itself if not
overridden, in the /3 version).

I think we should reword this clause to make it clear that the following
types do have preelaborable initialization:

   type T2 is new Ada.Finalization.Controlled with null record;
   procedure Initialize (X : in out T2; Y : Integer);
   --  Non overriding Initialize procedure

   type T3 is new T2 with null record;
   procedure Initialize (X : in out T3; Y : Integer);
   --  Overriding the above, but not the predefined Initialize

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

From: Randy Brukardt
Sent: Wednesday, January 26, 2011  10:32 PM

...
> 10.2.1(11.4/2) refers to controlled types with an overriding
> Initialize procedure (and 10.2.1(11.4/3) resulting from
> AI05-028 has similar language about "an Initialize procedure that is
> not a null procedure").
>
> This seems far to broard; the intent of the clause is certainly to
> apply only to an Initialize procedure that would override *the*
> predefined Initialize primitive declared for types
> Ada.Finalization.[Limited_]Controlled (or that procedure itself if not
> overridden, in the /3 version).

"far too broad"?? Wow, talk about overkill. This whole property of
preelaboratable initialization is a tiny corner case of not much value. Beyond
that, it's close to meaningless; the original idea of no runtime code is never
true for any controlled object in the canonical implementation (it has to be
added to a finalization chain of some sort).

Finally:

> I think we should reword this clause to make it clear that the
> following types do have preelaborable initialization:
>
>    type T2 is new Ada.Finalization.Controlled with null record;
>    procedure Initialize (X : in out T2; Y : Integer);
>    --  Non overriding Initialize procedure

is the sort of thing that only a compiler writer (or ACATS test writer) would
create. Calling a routine "Initialize" for a controlled type is an abuse of
overloading -- you have two routines with different purposes using the same
name. That's a bad idea. Beyond that, controlled types with null Initialize
routines aren't that common to begin with. Moreover, in the unlikely event that
someone did have a problem here, all they would need to do is change the name of
the badly named "Initialize" routine.

We could add a "To Be Honest" note to the AARM, but even that is more work than
this issue is worth.

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

From: Thomas Quinot
Sent: Tuesday, November  2, 2011  7:11 AM

Question 4 in AI05-028 is about relaxing the requirements for
preelaborable initialization for controlled types as follows:

> For question 4, change the second sentence of 10.2.1(11.4/2) as follows:
>
> However, a [user-defined] controlled type with an [overriding] Initialize procedure
> {that is not a null procedure} does not have preelaborable initialization.

The discussion for this change mentions "regaining" preelaborable
initialization:

> For question 4, it is clear that the case of a null Initialize procedure was overlooked.
> It seems useful to be able to "regain" preelaborable initialization by overriding
> Initialize with a null procedure.

I guess the intent is to make type T2 below have preelaborable
initialization:

   type T1 is new Ada.Finalization.Controlled with null record;
   procedure Initialize (X : in out T1);
   --  No PI because non-null

   type T2 is new T1 with null record;
   procedure Initialize (X : in out T2) is null;

However the change is ineffective in this respect: T2 is a derived type
whose parent does not have preelaborable initialization, so it does not
have preelaborable initialization anyway.

If T2 is intended to have preelaborable initialization, we probably need
an additional clause along the line of:

  A controlled type with a null Initialize primitive operation [AARM
  note: possibly derived from a controlled type that does not have PI]
  has preelaborable initialization if all of its components (including
  inherited ones) have preelaborable initialization.

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

From: Randy Brukardt
Sent: Wednesday, January 26, 2011  10:46 PM

Right.

The discussion in the AI seems to be bogus. Whether or not "regaining" PI is a
good idea, ignoring your parent type's non-null Initialize routine is a horrible
idea. It violates substitutability; and even if we ignore the academic stuff,
it's hard to imagine a case where there is an important initialization
requirement for the parent type which somehow disappears for a derived child
type. So this could hardly ever happen in practice.

That means it couldn't be worth trying to make it work, either in the language
wording or in any implementations. (And I'd expect that both would require
substantial work.)

Since the discussion in the AI isn't normative in any way, it's best to just
ignore it (it doesn't change the answer to the original question, or the
conclusion of the AI or the actual wording change).

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


Questions? Ask the ACAA Technical Agent