comp.lang.ada
 help / color / mirror / Atom feed
From: "Randy Brukardt" <randy@rrsoftware.com>
Subject: Re: Ada0Y anonymous access to self type
Date: Thu, 30 Sep 2004 18:49:34 -0500
Date: 2004-09-30T18:49:34-05:00	[thread overview]
Message-ID: <gdCdnTlyra3WBsHcRVn-qA@megapath.net> (raw)
In-Reply-To: pan.2004.09.30.20.31.43.819322@power.com.pl

"Wojtek Narczynski" <wojtek@power.com.pl> 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






      parent reply	other threads:[~2004-09-30 23:49 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-09-30 20:31 Ada0Y anonymous access to self type Wojtek Narczynski
2004-09-30 20:47 ` Matthew Heaney
2004-09-30 21:07   ` Wojtek Narczynski
2004-09-30 23:49 ` Randy Brukardt [this message]
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox