comp.lang.ada
 help / color / mirror / Atom feed
From: Adam Beneschan <adam@irvine.com>
Subject: Re: "limited with" packages
Date: Wed, 20 Jun 2007 08:38:06 -0700
Date: 2007-06-20T08:38:06-07:00	[thread overview]
Message-ID: <1182353886.851068.178990@j4g2000prf.googlegroups.com> (raw)
In-Reply-To: <1182345613.667367.212750@q69g2000hsb.googlegroups.com>

On Jun 20, 6:20 am, adam.betts...@gmail.com wrote:
> I have the following code:
>
> ---------------------------------------------------------------------------------------------------------------------------
> with my_package; use my_package;
> package other_package is
>    type type_one (<>) is private;
>    type type_one_pointer is access constant type_one'class;
>
>    function create (t_2: type_two'class) return type_one'class;
> ........
> end other_package;
> ---------------------------------------------------------------------------------------------------------------------------
> limited with other_package;
> package my_package is
>   type type_two is private;
>
>   function get_type_one (t_2: type_two'class) return
> other_package.type_one_pointer;
> .........
> end my_package
> ---------------------------------------------------------------------------------------------------------------------------
> package body my_package is
>
> function get_type_one (t_2: type_two'class) return
> other_package.type_one_pointer is
>   t_one_ptr : other_package.type_one_pointer;
> begin
>   t_one_ptr := new
> other_package.type_one'class'( other_package.create(t_2) );
> end get_type_one;
>
> end my_package;
> ---------------------------------------------------------------------------------------------------------------------------
>
> However, I'm getting the error:"create" not declared in
> "other_package"
>
> which I do not understand as it does not complain about the types
> (type_one and type_one_pointer). Maybe it is my misunderstanding of
> the "limited with" clause. Any help much appreciated.

See 10.1.1(12.1-12.3).  "limited with" gives you a limited view of a
package; the only things you get in the limited view are types (and
types inside nested packages), plus those types are viewed as if they
were incomplete types, in essence.  You don't get functions like
"create".  Put a regular "with other_package" on my_package's body:

with other_package;
package body my_package is......

                       -- Adam






  reply	other threads:[~2007-06-20 15:38 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-06-20 13:20 "limited with" packages adam.betts155
2007-06-20 15:38 ` Adam Beneschan [this message]
2007-06-20 16:06   ` adam.betts155
2007-06-20 16:32     ` Adam Beneschan
2007-06-20 16:27   ` adam.betts155
2007-06-20 18:13     ` Adam Beneschan
2007-06-20 18:27       ` Anh Vo
2007-06-20 18:44         ` Adam Beneschan
2007-06-21  8:13         ` adam.betts155
2007-06-22  5:10           ` Simon Wright
replies disabled

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