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.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,c71aef5bb0ff1a93 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-05-02 10:09:15 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news.uchicago.edu!newsswitch.lcs.mit.edu!newsfeed.mathworks.com.MISMATCH!newsfeed!nntp.TheWorld.com!not-for-mail From: Robert A Duff Newsgroups: comp.lang.ada Subject: Re: recursive types and generics Date: 02 May 2003 13:09:14 -0400 Organization: The World Public Access UNIX, Brookline, MA Message-ID: References: <3eb29aa6$1_3@news.arrakis.es> NNTP-Posting-Host: shell01.theworld.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: pcls4.std.com 1051895354 32680 199.172.62.241 (2 May 2003 17:09:14 GMT) X-Complaints-To: abuse@TheWorld.com NNTP-Posting-Date: Fri, 2 May 2003 17:09:14 +0000 (UTC) User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2 Xref: archiver1.google.com comp.lang.ada:36872 Date: 2003-05-02T13:09:14-04:00 List-Id: alfonso acosta 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