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=unavailable autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!feeder.eternal-september.org!aioe.org!.POSTED!not-for-mail From: "Dmitry A. Kazakov" Newsgroups: comp.lang.ada Subject: Re: Diamond diagram for 'with' Date: Thu, 22 Feb 2018 09:33:23 +0100 Organization: Aioe.org NNTP Server Message-ID: References: NNTP-Posting-Host: MyFhHs417jM9AgzRpXn7yg.user.gioia.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Complaints-To: abuse@aioe.org User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 X-Notice: Filtered by postfilter v. 0.8.3 Content-Language: en-US Xref: reader02.eternal-september.org comp.lang.ada:50542 Date: 2018-02-22T09:33:23+01:00 List-Id: On 22/02/2018 02:38, Randy Brukardt wrote: > "Dmitry A. Kazakov" wrote in message > news:p6k68f$9li$1@gioia.aioe.org... >> I would ask language lawyers regarding multiple with. >> >> Consider this: >> >> limited with Root.A; >> package Root is >> end Root; >> >> package Root.A is >> type T is ...; >> end Root.A; >> >> with Root.A; >> package Root.B is >> end Root.B; >> >> Now Root.B has both limited (inherited from Root) and full "with" of >> Root.A. So, may Root.B use Root.A.T? It cannot according to "limited with" >> and it can due to full "with". Which one to win? > > Off the top of my head, it should be the "full with". Generally, Ada allows > one to open more visibility, but you can't remove it. Deriving this formally > would be somewhat painful, but it has to be true, since the motivating use > for > limited with is something like: > > limited with P; > package Q is > ... > end Q; > > limited with Q; > package P is > ... > end P; > > with Q; > package body P is > -- Q is normally visible here. > end P; > > If the limited with "won" in the body, one could never access the full > package in the body, which would make actually implementing any mutually > dependent package hard. (You may want to call some primitive routine > declared in Q in the body of P, but that isn't possible for a "limited > with"). That is logical. A more permissive access should consume the less permissive one. > Since all withs work basically the same way, the same has to be true for a > child package. > > BTW, Root.A.T would be legal either way. But if it came from the limited > with, it would be an incomplete type (which has its own limitations). Yes, this is how I came to this, GNAT complained about incomplete types. So it is possible a compiler bug, however I worked it around anyway. I am keeping on avoiding "limited with", and the only time I lowered my guard, it bite me! (:-)) -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de