comp.lang.ada
 help / color / mirror / Atom feed
* Ada0Y limited with
@ 2004-09-30 22:23 Wojtek Narczynski
  2004-09-30 23:40 ` Randy Brukardt
  0 siblings, 1 reply; 5+ messages in thread
From: Wojtek Narczynski @ 2004-09-30 22:23 UTC (permalink / raw)


Hello,

(GNAT in gcc mainline refuses compile the example from the "An invitation
to Ada 2005" presentation, claiming "circular unit dependency" error, so
I have serious problems trying to understand how this is supposed to work.)

Do I need to declare an access type every time I want to use a a type from
the limited-withed package, or can I just use the access type declared in
the limited-withed package?

Which of the following is code illegal?

with Parts;
package Whole is

   type Whole_Type is record
      Part : Parts.Part_Type;
   end record;

   type Whole_Access is access all Whole_Type;

end Whole;
 
 
limited with Whole;
package Parts is
 
   type Part_Type is record
      Prev : Whole.Whole_Access;
      Next : access Whole.Whole_Type;
   end record;
 
end Parts;


Regards,
Wojtek



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

* Re: Ada0Y limited with
  2004-09-30 22:23 Ada0Y limited with Wojtek Narczynski
@ 2004-09-30 23:40 ` Randy Brukardt
  2004-10-01  7:52   ` Wojtek Narczynski
  0 siblings, 1 reply; 5+ messages in thread
From: Randy Brukardt @ 2004-09-30 23:40 UTC (permalink / raw)



"Wojtek Narczynski" <wojtek@power.com.pl> wrote in message
news:pan.2004.09.30.22.23.45.962614@power.com.pl...
> Hello,
>
> (GNAT in gcc mainline refuses compile the example from the "An invitation
> to Ada 2005" presentation, claiming "circular unit dependency" error, so
> I have serious problems trying to understand how this is supposed to
work.)
>
> Do I need to declare an access type every time I want to use a a type from
> the limited-withed package, or can I just use the access type declared in
> the limited-withed package?
>
> Which of the following is code illegal?
>
> with Parts;
> package Whole is
>
>    type Whole_Type is record
>       Part : Parts.Part_Type;
>    end record;
>
>    type Whole_Access is access all Whole_Type;
>
> end Whole;
>
>
> limited with Whole;
> package Parts is
>
>    type Part_Type is record
>       Prev : Whole.Whole_Access;
>       Next : access Whole.Whole_Type;
>    end record;
>
> end Parts;

Limited with always gives you an incomplete view of any types, so that
clearly applies to Whole_Access as well.

The reason for expanding the use of anonymous access types is to avoid the
junk conversions needed if you define named access types everywhere that you
use limited withed packages.

So, component Prev is wrong; it should look like component Next.

                 Randy Brukardt.






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

* Re: Ada0Y limited with
  2004-09-30 23:40 ` Randy Brukardt
@ 2004-10-01  7:52   ` Wojtek Narczynski
  2004-10-01 18:30     ` Randy Brukardt
  0 siblings, 1 reply; 5+ messages in thread
From: Wojtek Narczynski @ 2004-10-01  7:52 UTC (permalink / raw)


On Thu, 30 Sep 2004 18:40:36 -0500, Randy Brukardt wrote:

> So, component Prev is wrong; it should look like component Next.

But then it will not be legal to assign 'Whole.Whole_Access' to 'access
Whole_Type' members?

Thank you,
Wojtek



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

* Re: Ada0Y limited with
  2004-10-01  7:52   ` Wojtek Narczynski
@ 2004-10-01 18:30     ` Randy Brukardt
  2004-10-01 18:51       ` Wojtek Narczynski
  0 siblings, 1 reply; 5+ messages in thread
From: Randy Brukardt @ 2004-10-01 18:30 UTC (permalink / raw)


"Wojtek Narczynski" <wojtek@power.com.pl> wrote in message
news:pan.2004.10.01.07.52.22.467934@power.com.pl...
> On Thu, 30 Sep 2004 18:40:36 -0500, Randy Brukardt wrote:
>
> > So, component Prev is wrong; it should look like component Next.
>
> But then it will not be legal to assign 'Whole.Whole_Access' to 'access
> Whole_Type' members?

It is legal; named access types implicitly convert to anonymous access types
as needed. (See 8.6(25)). That's even true in Ada 95, although the rule has
been broadened for Ada 2005.

To go to the named type from the anonymous one, you'd need a type
conversion.

But you may not need the named type at all, since anonymous types can be
used in almost all contexts.

                       Randy.







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

* Re: Ada0Y limited with
  2004-10-01 18:30     ` Randy Brukardt
@ 2004-10-01 18:51       ` Wojtek Narczynski
  0 siblings, 0 replies; 5+ messages in thread
From: Wojtek Narczynski @ 2004-10-01 18:51 UTC (permalink / raw)


Randy,

Great. Now I am really looking forward to those cool features.

Thank you for your answer. For all your answers.

Regards,
Wojtek



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

end of thread, other threads:[~2004-10-01 18:51 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-09-30 22:23 Ada0Y limited with Wojtek Narczynski
2004-09-30 23:40 ` Randy Brukardt
2004-10-01  7:52   ` Wojtek Narczynski
2004-10-01 18:30     ` Randy Brukardt
2004-10-01 18:51       ` Wojtek Narczynski

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