comp.lang.ada
 help / color / mirror / Atom feed
From: "Randy Brukardt" <randy@rrsoftware.com>
Subject: Re: Diamond diagram for 'with'
Date: Wed, 21 Feb 2018 19:38:24 -0600
Date: 2018-02-21T19:38:24-06:00	[thread overview]
Message-ID: <p6l6ug$lst$1@franka.jacob-sparre.dk> (raw)
In-Reply-To: p6k68f$9li$1@gioia.aioe.org

"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").

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).

                                Randy.



  reply	other threads:[~2018-02-22  1:38 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 [this message]
2018-02-22  8:33   ` Dmitry A. Kazakov
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