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!g37g2000prf.googlegroups.com!not-for-mail From: Adam Beneschan Newsgroups: comp.lang.ada Subject: Re: "limited with" packages Date: Wed, 20 Jun 2007 09:32:37 -0700 Organization: http://groups.google.com Message-ID: <1182357157.972402.299280@g37g2000prf.googlegroups.com> References: <1182345613.667367.212750@q69g2000hsb.googlegroups.com> <1182353886.851068.178990@j4g2000prf.googlegroups.com> <1182355561.359900.160710@k79g2000hse.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 1182357158 30579 127.0.0.1 (20 Jun 2007 16:32:38 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Wed, 20 Jun 2007 16:32:38 +0000 (UTC) In-Reply-To: <1182355561.359900.160710@k79g2000hse.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: g37g2000prf.googlegroups.com; posting-host=66.126.103.122; posting-account=cw1zeQwAAABOY2vF_g6V_9cdsyY_wV9w Xref: g2news1.google.com comp.lang.ada:16277 Date: 2007-06-20T09:32:37-07:00 List-Id: On Jun 20, 9:06 am, adam.betts...@gmail.com wrote: > Really thanks. I've spent a couple of hours banging my head about > this, in the end I programmed around it. I can't believe the solution > is so simple. Not to make excuses but I'm relatively new to Ada (few > months), and I'm trying to use most of the advanced features as my > project requires it. I think I lack a thorough understanding of how > the Ada compiler works. So, does the "limited with" clause only apply > at the spec level? You wouldn't want to use it on a body. "limited with" is a new feature of Ada. The purpose is to handle a situation where you want to write a package P1 that uses types declared in P2, and similarly P2 that uses types declared in P1. (You might have record structures in P1 and P2 that point to each other.) The problem was that you couldn't compile P1 without compiling P2 first, and you couldn't compile P2 without compiling P1 first, and you couldn't get a chicken until you had the egg first, and ... you get the idea. "limited with" was a solution to this. In your example, you can compile My_Package's spec without compiling Other_Package first; at some point, Other_Package will undergo a very simple scan just to see what type names are available, and My_Package's spec can then use those type names, but in a very restricted way---about the only thing you can do is to declare an access type that points to it. (In particular, I believe that your function declaration that returns a type_one_pointer is illegal, because the compiler won't know enough about type_one_pointer at that point. You'll need to move type_one_pointer to My_Package.) After you compile My_Package's spec, you can compile Other_Package, and then you can compile the bodies. Since Other_Package has been compiled by that time, there's no longer any need for a "limited with Other_Package"; at that point you will want to do a normal "with". I hope this helps give you a general idea of what's going on. -- Adam