From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,79d82904f3b7ef79 X-Google-Attributes: gid103376,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!postnews.google.com!d30g2000prg.googlegroups.com!not-for-mail From: Adam Beneschan Newsgroups: comp.lang.ada Subject: Re: "limited with" packages Date: Wed, 20 Jun 2007 11:13:36 -0700 Organization: http://groups.google.com Message-ID: <1182363216.698917.34860@d30g2000prg.googlegroups.com> References: <1182345613.667367.212750@q69g2000hsb.googlegroups.com> <1182353886.851068.178990@j4g2000prf.googlegroups.com> <1182356849.607952.278940@q75g2000hsh.googlegroups.com> NNTP-Posting-Host: 66.126.103.122 Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" X-Trace: posting.google.com 1182363218 8952 127.0.0.1 (20 Jun 2007 18:13:38 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Wed, 20 Jun 2007 18:13:38 +0000 (UTC) In-Reply-To: <1182356849.607952.278940@q75g2000hsh.googlegroups.com> User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.7.12) Gecko/20050922 Fedora/1.7.12-1.3.1,gzip(gfe),gzip(gfe) Complaints-To: groups-abuse@google.com Injection-Info: d30g2000prg.googlegroups.com; posting-host=66.126.103.122; posting-account=cw1zeQwAAABOY2vF_g6V_9cdsyY_wV9w Xref: g2news1.google.com comp.lang.ada:16279 Date: 2007-06-20T11:13:36-07:00 List-Id: On Jun 20, 9:27 am, adam.betts...@gmail.com wrote: > Adam Beneschan wrote: > > 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 > > However, it now seems I have another issue, with similar code... > > --------------------------------------------------------------------------------------------------------------------------- > with my_package; use my_package; > package other_package is > type type_one (<>) is private; > > 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; > > procedure get_type_one (t_2: in out type_two'class; t_1: out > other_package.type_one'class); > ......... > end my_package > --------------------------------------------------------------------------------------------------------------------------- > package body my_package is > procedure get_type_one (t_2: in out type_two'class; t_1: out > other_package.type_one'class); > begin > t_1 := create(t_2); > end get_type_one; > end my_package; > > --------------------------------------------------------------------------------------------------------------------------- > > This time the compiler is complaining that: > 1) procedure get_type_one in the package body of my_package is "not > fully conformant with declaration" in the spec and that, > 2) the type of t_1 does not match I think that's a compiler bug. -- Adam