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,FREEMAIL_FROM, INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,e94a7e4f6f888766 X-Google-Attributes: gid103376,public From: "Vladimir Olensky" Subject: Re: Self-referential types Date: 1999/10/12 Message-ID: #1/1 X-Deja-AN: 535581337 References: <7ttb4a$8mq$1@nnrp1.deja.com> Organization: Posted via Supernews, http://www.supernews.com X-MimeOLE: Produced By Microsoft MimeOLE V4.72.3110.3 Newsgroups: comp.lang.ada X-Complaints-To: newsabuse@supernews.com Date: 1999-10-12T00:00:00+00:00 List-Id: Ted Dennison wrote in message <7ttb4a$8mq$1@nnrp1.deja.com>... >I'm trying to create my first self referential type. But there's >obviously something about this technique I'm missing, because all >attempts produce compiler errors in multiple compilers. > >Below is a code sample that is taken directly from Cohen's AAASL, >section 11.8.3: > >procedure Test is > > type Cell_Type; > > type List_Type is access all Cell_Type; > > type Cell_Type is > limited record > Contents_Part : String (1..20); > Next_Cell_Part : List_Type := Cell_Type'Access; > Previous_Cell_Part : List_Type := Cell_Type'Access; > end record; >begin > null; >end Test; It seems that this example was not tested. How it is possible to initialize access variable by the initial value that is access attribute to type ? Access attributes can not be applied to type. It may only be applied to some object but not to its description. Also compiles are probably giving misleading error messages. If you change your example to: ------------------------------------- Procedure Test is type Cell_Type; type List_Type is access all Cell_Type; type Cell_Type is limited record Contents_Part : String (1..20); Next_Cell_Part : List_Type := null; Previous_Cell_Part : List_Type := null; end record; Wrong_Initialization : List_Type := Cell_Type'Access; begin null; end Test; ------------------------------------------ than you will have right error message regarding Wrong_Initialization varible: >>>test.adb:14:37: "Access" attribute cannot be applied to type gnatmake: "test.adb" compilation error Regards, Vladimir Olensky