comp.lang.ada
 help / color / mirror / Atom feed
* Ada0Y anonymous access to self type
@ 2004-09-30 20:31 Wojtek Narczynski
  2004-09-30 20:47 ` Matthew Heaney
  2004-09-30 23:49 ` Randy Brukardt
  0 siblings, 2 replies; 4+ messages in thread
From: Wojtek Narczynski @ 2004-09-30 20:31 UTC (permalink / raw)
  To: wojtek

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?

There was something about taming the "access types proliferation" in Ada0Y...

Regards,
Wojtek



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Ada0Y anonymous access to self type
  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
  1 sibling, 1 reply; 4+ messages in thread
From: Matthew Heaney @ 2004-09-30 20:47 UTC (permalink / raw)



"Wojtek Narczynski" <wojtek@power.com.pl> wrote in message
news:pan.2004.09.30.20.31.43.819322@power.com.pl...
>
> 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?
>
> There was something about taming the "access types proliferation" in
Ada0Y...

Leave in the forward declaration of type Foo_Type, and see if that compiles.






^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Ada0Y anonymous access to self type
  2004-09-30 20:47 ` Matthew Heaney
@ 2004-09-30 21:07   ` Wojtek Narczynski
  0 siblings, 0 replies; 4+ messages in thread
From: Wojtek Narczynski @ 2004-09-30 21:07 UTC (permalink / raw)


On Thu, 30 Sep 2004 16:47:00 -0400, Matthew Heaney wrote:

> Leave in the forward declaration of type Foo_Type, and see if that compiles.

type Foo_Type is record
   Next : access Foo_Type;
end record;

You mean just this alone? It does not, either.


Regards,
Wojtek



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Ada0Y anonymous access to self type
  2004-09-30 20:31 Ada0Y anonymous access to self type Wojtek Narczynski
  2004-09-30 20:47 ` Matthew Heaney
@ 2004-09-30 23:49 ` Randy Brukardt
  1 sibling, 0 replies; 4+ messages in thread
From: Randy Brukardt @ 2004-09-30 23:49 UTC (permalink / raw)


"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






^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2004-09-30 23:49 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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 is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox