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-Thread: 103376,c58d23b838cc6510 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news1.google.com!news.glorb.com!border1.nntp.dca.giganews.com!nntp.giganews.com!local1.nntp.dca.giganews.com!nntp.megapath.net!news.megapath.net.POSTED!not-for-mail NNTP-Posting-Date: Thu, 30 Sep 2004 18:48:27 -0500 From: "Randy Brukardt" Newsgroups: comp.lang.ada References: Subject: Re: Ada0Y anonymous access to self type Date: Thu, 30 Sep 2004 18:49:34 -0500 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.50.4807.1700 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4910.0300 Message-ID: NNTP-Posting-Host: 64.32.209.38 X-Trace: sv3-lDLnyIH3N6vgGal+byAm+kdU5vOgd9/m0tdQXgkXy4DTFaEy2wHYq8DY2mQ8/10memgZrwB8XE0bHZI!GUMcLaQDp0NVIf1dG0dbgGaQdjbNg0k5NQSgiaNpAaKjACdgfTtAa7A8ZCjXmTe1M7FyuiO4qNc6 X-Complaints-To: abuse@megapath.net X-DMCA-Complaints-To: abuse@megapath.net X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly X-Postfilter: 1.3.17 Xref: g2news1.google.com comp.lang.ada:4471 Date: 2004-09-30T18:49:34-05:00 List-Id: "Wojtek Narczynski" wrote in message news:pan.2004.09.30.20.31.43.819322@power.com.pl... > Hello, > > I am trying to understand the Ada0Y goodies already implemented in gcc > mainline. I've just run into such an issue: > > type Foo_Type; > > -- This compiles > type Bar_Type is record > Foo : access Foo_Type; > end record; > > -- This does not > type Foo_Type is record > Next : access Foo_Type; > end record; > > For the Foo_Type record the compiler complains that "type declaration > cannot refer to itself", but does this restriction serve any purpose? Well, it did in Ada 95, and we forgot to remove it for anonymous access types. In Ada 95, the name of a type inside of that type refers to the current instance of the type. That can be seen in: type Foo_Type; type Foo_Access is access all Foo_Type; type Foo_Type is limited record Next : Foo_Access := Foo_Type'Access; end record; but it also is true for task bodies (where it's a lot more important). This problem has been discovered by several people, and we are working on a fix (AI-382). The problem is it takes a lot of care to get this exactly right. One proposed rule would have allowed: type Foo_Type is limited record Next : access Foo_Type := new Foo_Type'(Foo_Type); end record; which I'm pretty sure we don't want to be legal! But we also have to be careful not to break task bodies, 'cause there is a lot of code out there using tasks. There are also issues as to how much information can be used about the partially defined type. You want to be able to use 'Class, but not 'Size. If you really care, read the minutes of the most recent ARG meeting (posted yesterday). Randy Brukardt