From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: Diamond diagram for 'with'
Date: Thu, 22 Feb 2018 09:33:23 +0100
Date: 2018-02-22T09:33:23+01:00 [thread overview]
Message-ID: <p6lv8i$lbo$1@gioia.aioe.org> (raw)
In-Reply-To: p6l6ug$lst$1@franka.jacob-sparre.dk
On 22/02/2018 02:38, Randy Brukardt wrote:
> "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> 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
next prev parent reply other threads:[~2018-02-22 8:33 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-02-21 16:20 Diamond diagram for 'with' Dmitry A. Kazakov
2018-02-22 1:38 ` Randy Brukardt
2018-02-22 8:33 ` Dmitry A. Kazakov [this message]
2018-02-22 9:27 ` J-P. Rosen
2018-02-22 23:29 ` Randy Brukardt
2018-02-22 10:53 ` briot.emmanuel
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox