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,487310d7e1471eac X-Google-Attributes: gid103376,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!postnews.google.com!50g2000hsm.googlegroups.com!not-for-mail From: Adam Beneschan Newsgroups: comp.lang.ada Subject: Re: parent package referring to child Date: Wed, 10 Oct 2007 13:20:07 -0700 Organization: http://groups.google.com Message-ID: <1192047607.865747.220890@50g2000hsm.googlegroups.com> References: <1191997397.865251.322480@d55g2000hsg.googlegroups.com> <1192028394.287114.182670@o3g2000hsb.googlegroups.com> <1192042440.388079.69040@o80g2000hse.googlegroups.com> <1192044748.953712.248880@v3g2000hsg.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 1192047608 20409 127.0.0.1 (10 Oct 2007 20:20:08 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Wed, 10 Oct 2007 20:20:08 +0000 (UTC) In-Reply-To: <1192044748.953712.248880@v3g2000hsg.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: 50g2000hsm.googlegroups.com; posting-host=66.126.103.122; posting-account=ps2QrAMAAAA6_jCuRt2JEIpn5Otqf_w0 Xref: g2news2.google.com comp.lang.ada:2425 Date: 2007-10-10T13:20:07-07:00 List-Id: On Oct 10, 12:32 pm, Matthew Heaney wrote: > On Oct 10, 2:54 pm, Vadim Godunko wrote: > > > > > > You can do this in Ada05: > > > > limited with P.C; > > > package P is > > > procedure Op (O : in out P.C.T); > > > O : access P.C.T > > You can't use "in out" mode, T have only limited view at this point. > > No, that's wrong. In this case you can use mode inout because type T > is tagged (meaning that it's passed by reference). I don't see what the parameter mode has to do with it. I can't find a rule that would make "procedure Op (O : in P.C.T);" illegal. Also, GNAT accepts it in a small test case I just tried, although that doesn't necessarily mean much (see below). Then again, on second reading, maybe I read too much into what you said. Also, the "by reference" comment isn't relevant either. If the package that you're LIMITED WITH'ing contains an untagged type, you can't use it as a parameter of any mode except "access", regardless of whether it's a by-reference type. The relevant rules are 3.10.1(5-9), which spell out what an "incomplete view" of a type can be used for (including a type declared in a LIMITED WITH'ed package); the rules are different for tagged and untagged types (or, technically, tagged and untagged incomplete views of types). > Try it! That doesn't seem to be particularly good advice. You can "try it" only by running it through a compiler, but that still won't tell you whether the code is illegal because many compilers accept a lot of code that they shouldn't. I know GNAT has accepted plenty of illegal code in the past. (Some of the bugs have been fixed in later versions.) -- Adam