comp.lang.ada
 help / color / mirror / Atom feed
* Forwarding declaration?
@ 2005-04-01  8:36 Andrew
  2005-04-01  9:03 ` Dmitry A. Kazakov
  0 siblings, 1 reply; 3+ messages in thread
From: Andrew @ 2005-04-01  8:36 UTC (permalink / raw)


I have need of a forwarding declaration.  How do I do that in Ada?

--- example1 ---
type Boob is record
    Avar : A_Ptr;
end record;
type Boob_Ptr is access all Boob;

task type A(booby: Boob_Ptr) is
   . . .
end A;
type A_Ptr is access all A;
------------------

compiler says (and I say) that A_Ptr is undefined for Boob.

Now if I could use a temporary placeholder for A_Ptr (a forwarding
declaration) then the compiler and I would be happy.

--- example2 ---
-- forwarding declaration
temporary declaration of A_Ptr;

type Boob is record
    Avar : A_Ptr;
end record;
type Boob_Ptr is access all Boob;

task type A(booby: Boob_Ptr) is
   . . .
end A;
type A_Ptr is access all A;
------------------

Thanks,

Andrew




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

* Re: Forwarding declaration?
  2005-04-01  8:36 Forwarding declaration? Andrew
@ 2005-04-01  9:03 ` Dmitry A. Kazakov
  2005-04-01  9:22   ` Andrew
  0 siblings, 1 reply; 3+ messages in thread
From: Dmitry A. Kazakov @ 2005-04-01  9:03 UTC (permalink / raw)


On 1 Apr 2005 00:36:22 -0800, Andrew wrote:

> I have need of a forwarding declaration.  How do I do that in Ada?
> 
> --- example1 ---
> type Boob is record
>     Avar : A_Ptr;
> end record;
> type Boob_Ptr is access all Boob;
> 
> task type A(booby: Boob_Ptr) is
>    . . .
> end A;
> type A_Ptr is access all A;
> ------------------
> 
> compiler says (and I say) that A_Ptr is undefined for Boob.
> 
> Now if I could use a temporary placeholder for A_Ptr (a forwarding
> declaration) then the compiler and I would be happy.
> 
> --- example2 ---
> -- forwarding declaration
> temporary declaration of A_Ptr;
> 
> type Boob is record
>     Avar : A_Ptr;
> end record;
> type Boob_Ptr is access all Boob;
> 
> task type A(booby: Boob_Ptr) is
>    . . .
> end A;
> type A_Ptr is access all A;
> ------------------

type A; -- Forward declaration of A
type A_Ptr is access all A;

type Boob is record
  Avar : A_Ptr;
end record;
type Boob_Ptr is access all Boob;

task type A (booby : access Boob) is -- No need in pointers here
   ...
end A;

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de



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

* Re: Forwarding declaration?
  2005-04-01  9:03 ` Dmitry A. Kazakov
@ 2005-04-01  9:22   ` Andrew
  0 siblings, 0 replies; 3+ messages in thread
From: Andrew @ 2005-04-01  9:22 UTC (permalink / raw)


Thanks Dmitry.
I found the example I had in my mind from Cohen's book on page 526.  I
came back to c.l.a to say that I had found it.  Before I could you had
already posted the answer.  I knew it could be done with records but
wasn't sure how to do it with task types.  I also had:

task type A;

instead of

type A;

Also,  thanks for the tip on the access parameter!

Andrew




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

end of thread, other threads:[~2005-04-01  9:22 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-04-01  8:36 Forwarding declaration? Andrew
2005-04-01  9:03 ` Dmitry A. Kazakov
2005-04-01  9:22   ` Andrew

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