From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,2683e73445986fa2 X-Google-Attributes: gid103376,public From: Richard D Riehle Subject: Re: Derivation + Access Discriminant = Headaches Date: 1999/03/19 Message-ID: <7cu23r$miu@dfw-ixnews5.ix.netcom.com>#1/1 X-Deja-AN: 456572601 References: Organization: Netcom X-NETCOM-Date: Fri Mar 19 11:39:07 AM CST 1999 Newsgroups: comp.lang.ada Date: 1999-03-19T11:39:07-06:00 List-Id: In article , Matthew Heaney wrote: >Below is a tagged type hierarchy. [ deleted because it is shown in Matthew's code example ] > >My expectation is that this should be legal, because NT is in T'Class, >and should therefore be allowed to replace the discriminant that >designates T'Class. On GNAT, an equivalent type hierarchy works fine. For simplicity I did not separate this into separate packages or use private types. However, the same discriminant rules should apply. package Discriminant_Derivations is type Tack is tagged limited null record; type Tack_Reference is access all Tack'Class; function Get return Tack_Reference; type Tack_N (Data : access Tack'Class) is new Tack with null record; type Tack_N1(Data : access Tack'Class) is new Tack_N(Data) with null record; -- This derivation constrains with a function call type Tack_N1(Data : access Tack'Class) is new Tack_N(Get) with null record; end Discriminant_Derivations; I wonder if this is OK on other Ada 95 compilers. Have not tried Aonix with it yet. Do not have Rational Apex handy. Richard Riehle richard@adaworks.com http://www.adaworks.com > >--STX >package P is > > type T is abstract tagged limited private; > > type NT (O : access T'Class) is > abstract new T with private; > >private > > type T is abstract tagged limited null record; > > type NT (O : access T'Class) is new T with null record; > >end P; > > >with P; use P; >package Q is > > type NNT (O : access NT'Class) is > new NT with private; > >private > > type NNT (O : access NT'Class) is > new NT (O) with null record; > >end Q; > > >