From: Robert A Duff <bobduff@shell01.TheWorld.com>
Subject: Re: recursive types and generics
Date: 02 May 2003 13:09:14 -0400
Date: 2003-05-02T13:09:14-04:00 [thread overview]
Message-ID: <wcck7d9qnr9.fsf@shell01.TheWorld.com> (raw)
In-Reply-To: 3eb29aa6$1_3@news.arrakis.es
alfonso acosta <alfonso_acosta_mail@yahoo.es> writes:
> Hi:
>
> I need to code a recursive type: a Sequence which could contain
> sequences of the same type. Im trying to use a generic package for that
> purpouse. I provide a simplified example:
>
> -------------------------------------------------------------------------
> type Elem_Type is (Nothing, Int, Seq);
>
> type Seq_Acces;
>
> type Seq_Elem (Const : Elem_Type := Nothing) is
> record
> case Const is
> when Nothing => null;
> when Int => I : Integer;
> when Seq => S : Seq_Access;
> -- "invalid use of type before its full declaration"
> end case;
> end record;
>
> package Myseq is new Sequence (Element => Seq_Elem);
>
> type Seq_Access is access Myseq.Sequence; -- provided by the generic
> -- package
> --------------------------------------------------------------------------
>
> Any ideas about fixing it?
>
> Alfonso Acosta
How about something like this?
type Seq_Elem is tagged limited null record;
package Myseq is new Sequence (Element => Seq_Elem'Class);
type Seq_Access is access Myseq.Sequence;
type Int_Seq_Elem is new Seq_Elem with
record
I: Integer;
end record;
type Seq_Seq_Elem is new Seq_Elem with
record
S: Seq_Access;
end record;
- Bob
next prev parent reply other threads:[~2003-05-02 17:09 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-05-02 16:19 recursive types and generics alfonso acosta
2003-05-02 17:09 ` Robert A Duff [this message]
2003-05-02 17:12 ` Ludovic Brenta
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox