comp.lang.ada
 help / color / mirror / Atom feed
From: stt@inmet.inmet.com
Subject: Re: layering with discriminants
Date: 6 Mar 91 20:12:00 GMT	[thread overview]
Message-ID: <20600087@inmet> (raw)
In-Reply-To: 90348@tut.cis.ohio-state.edu


In article <44963@ut-emx.uucp> hasan@emx.utexas.edu (David A. Hasan) writes:
 . . .
>My problem revolves around the fact that the DEC compiler rejects
>the presence of the discriminant in the full declaration of the adt in
>the private part of g_highLevel, since the declaration is not a record.
>But the declaration is *derived* from a record.

>My conclusion is that it is not legal to derive
>types with discriminants from parents with discriminants.  
>If this is true, is there anyway to achieve an equivalent effect?

This is true, and it is admittedly annoying.  One way is
to make the private type into a record containing the parent
as a component.  Some compilers are clever enough to share
the space occupied by the component's discriminants for
the enclosing record's discriminants (since they must always
have the same value).

For example:

    type Blah(X : Integer) is private;

private

    type Blah(X : Integer) is record
        Parent : Parent_Type(X);
    end record;

-S. Tucker Taft
Ada 9X Mapping/Revision Team
Intermetrics, Inc.
Cambridge, MA  02138

P.S. This annoyance has been identified as something which
might be fixable in Ada 9X without too much change, perhaps
by allowing:

    type Blah(X : Integer) is new Parent_Type(X);

in the private part which would make Blah be a derivative of 
Parent_Type, but also allow the declaration to 
fulfill "type Blah(X : Integer) is private;"

It is too early to tell whether such a proposal will survive the
9X review process.

  reply	other threads:[~1991-03-06 20:12 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1991-03-02  0:28 layering with discriminants David A. Hasan
1991-03-04  2:52 ` Joe Hollingsworth
1991-03-06 20:12   ` stt [this message]
1991-03-05  1:56 ` Robert I. Eachus
  -- strict thread matches above, loose matches on Subject: below --
1991-03-05 18:00 Dave Williamson
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox