Rationale for Ada 2005: 7. Epilogue

RUSTOP
BACKNEXT

ENG

3.1 Aggregates for private types (AI- 389)

@ The <> notation was introduced for aggregates to mean the default value if any. See paper 3 section 4. A curiosity is that we can write

  1        type Secret is private;
  2        type Visible is
  3                record
  4                        A : Integer;
  5                        S : Secret;
  6                end record;
  7        X : Visible := (A => 77; S => <>);

@ but we cannot write

  1        S : Secret := <>; -- illegal

@ The argument is that this would be of little use since the components take their default values anyway.

@ For uniformity AI-389 proposed allowing

  1        S : Secret := (others => <>);

@ for private types and also for task and protected types. One advantage would be that we could then write

  1        S : constant Secret := (others => <>);

@ whereas at the moment it is not possible to declare a constant of a private type because we are unable to give an initial value.

@ However, discussion of this issue lead into a quagmire concerning the related AI-413 and in the end both were abandoned.

3.2 Partial generic instantiation (AI-359)

@ Certain attempts to use signature packages lead to circularities. The AI outlines the following example

  1        generic
  2                type Element is private;
  3                type Set is private;
  4                with function Union (L, R : Set) return Set is <>;
  5                with function Intersection (L, R : Set) return Set is <>;
  6                ... -- and so on package Set_Signature is end;

@ Remember that a signature is a generic package consisting only of a specification. When we instantiate it, the effect is to assert that the actual parameters are consistent and the instantiation provides a name to refer to them as a group.

@ If we now attempt to write

  1        generic
  2                type Elem is private;
  3                with function Hash (E : Elem) return Integer;
  4        package Hashed_Sets is
  5                type Set is private;
  6                function Union (L, R : Set) return Set;
  7                function Intersection (L, R : Set) return Set;
  8                ...
  9                package Signature is new Set_Signature (Elem, Set);
 10        private
 11                type Set is
 12                        record
 13                                ...
 14                        end record;
 15        end Hashed_Sets;

@ then we are in trouble. The problem is that the instantiation of Set_Signature tries to freeze the type Set prematurely.

@ Other similar examples concern the use of access types with private types. The essence of the problem is that we want to instantiate a package with a private type before the full declaration of that type.

@ The solution proposed was to split an instantiation into two parts, a partial instantiation and a full (that is, normal) instantiation. The partial instantiation might take the form

  1        package P is new G (Private_Type) with private;

@ and this can be done with the partial view of the type. The full instantiation can then be given after the full declaration of the type.

@ This fell by the wayside at the last minute largely because of fears that awkward situations might be introduced inadvertently.

. .