[comp.lang.ada] Derived private type in Ada 9X

stt@inmet.UUCP (03/04/88)

Here's another gripe for the Ada 9X effort:

It is quite annoying that private types with
discriminants may not be defined as derived types,
where the parent type has matching or conforming
discriminants.

For example, the following is currently illegal, due to
7.4.1:3 -- "If a private type declaration includes a discriminant
part, the full declaration must include a discriminant part that
conforms . . . and its type definition must be a record type
definition."

package Public_Pkg is
    type Public_Rec(D : Boolean := True) is record
        case D is
            when True => X : Integer;
            when False => Y : Float;
        end case;
    end record;
end Public_Pkg;

with Public_Pkg;
package Private_Pkg is
    type Private_Rec(D : Boolean := True) is private;
private
    type Private_Rec is new Public_Pkg.Public_Rec;
end Private_Pkg;

Here is some alternate wording which would allow this situation:

"If a private type includes a discriminant, the full
declaration must include a discriminant part..., or
must be a derived type definition where the parent
type is a type with discriminants whose definition
conforms."

Tucker Taft
c/o Intermetrics
Cambridge, MA  02138