From: Richard D Riehle <laoXhai@ix.netcom.com>
Subject: Re: Derivation + Access Discriminant = Headaches
Date: 1999/03/19
Date: 1999-03-19T11:39:07-06:00 [thread overview]
Message-ID: <7cu23r$miu@dfw-ixnews5.ix.netcom.com> (raw)
In-Reply-To: m3r9qlvpuv.fsf@mheaney.ni.net
In article <m3r9qlvpuv.fsf@mheaney.ni.net>,
Matthew Heaney <matthew_heaney@acm.org> 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;
>
>
>
next prev parent reply other threads:[~1999-03-19 0:00 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
1999-03-19 0:00 Derivation + Access Discriminant = Headaches Matthew Heaney
1999-03-19 0:00 ` Richard D Riehle [this message]
1999-03-19 0:00 ` Matthew Heaney
1999-03-19 0:00 ` Stephen Leake
1999-03-20 0:00 ` Richard D Riehle
1999-03-20 0:00 ` Nick Roberts
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox