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=-0.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,999932ecc319322a X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news4.google.com!newsfeed.stanford.edu!newsmi-us.news.garr.it!newsmi-eu.news.garr.it!NewsITBone-GARR!irazu.switch.ch!switch.ch!news.belwue.de!newsfeed.arcor.de!news.arcor.de!not-for-mail From: "Dmitry A. Kazakov" Subject: Re: advice on package design Newsgroups: comp.lang.ada User-Agent: 40tude_Dialog/2.0.14.1 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Reply-To: mailbox@dmitry-kazakov.de Organization: cbb software GmbH References: <1110212638.336123.298580@l41g2000cwc.googlegroups.com> <1gbk0qx2sgzpg$.sltzfssofla8$.dlg@40tude.net> <3jok3ghqqls8$.1rrsonb8jsurt$.dlg@40tude.net> Date: Sun, 13 Mar 2005 10:23:02 +0100 Message-ID: <88zllqj1min5$.fqqxis9i327d$.dlg@40tude.net> NNTP-Posting-Date: 13 Mar 2005 10:22:51 MET NNTP-Posting-Host: 82c3d792.newsread4.arcor-online.net X-Trace: DXC=kn2;A3QD[nk0_l3b[L=KQc:ejgIfPPlddjW\KbG]kaMhGSi?jHD8GO`AVbF>C\b4nf[6LHn;2LCVnCOgUkn_?_Yo5QBjmTohW`c X-Complaints-To: abuse@arcor.de Xref: g2news1.google.com comp.lang.ada:9298 Date: 2005-03-13T10:22:51+01:00 List-Id: On 12 Mar 2005 16:59:26 -0500, Robert A Duff wrote: > "Dmitry A. Kazakov" writes: > >> On 12 Mar 2005 14:57:17 -0500, Robert A Duff wrote: >> >>> If I were [re]designing Ada, I would make 'use' transitive. That is, >>> if Foo says "use Linked_List" that would make the contents of >>> Linked_List directly visible in Foo, and anything that says "use Foo;" >>> would have direct visibility on everything directly visible in Foo -- >>> not just the things *declared* in Foo. Or something like that. >> >> Yes, I really miss it. What about: >> >> use all ; >> >> or >> >> use package ; >> >> with the effect importing the specification of the package? Also, >> differently to use, it should prevent hiding. So: >> >> package A is >> Foo (X : Integer); >> end A; >> >> with A; >> package B is >> use all A; >> Foo (X : out Integer); -- Illegal, can't hide A.Foo >> end B; > > Well, I happen to think that *all* hiding is evil. > I would make the above legal, but all calls to Foo would be ambiguous, > and therefore illegal. That makes sense, but it might be difficult for the programmer to resolve the problem. Somewhere in 20th child package of B he calls Foo and, oops, it is ambiguous. I think it is better to keep all scopes clean from the beginning. > Ichbiah defined "Beaujolais Effect" to mean that if you add a subprogram > to a use-d package, and that causes a legal program to change it's > meaning (to another legal program) you have a Beaujolais Effect. > And Beaujolais Effects are bad. Ada 83 had some Beaujolais Effects, > but they were pretty obscure, and we eliminated them in Ada 95. > > But I think he should have extended that definition to include all > visibility, not just use-visibility. So a local X should not hide a > use-visible X, but be ambiguous with it. Yes. Even in the cases like: declare I : Integer; begin for I in A'Range loop A (I) := 0; end loop; However I'd like to get error message one line above than you. > And similar rules for record > (extension) components. I think that this case is not so simple. IMO record components should be treated as primitive operations (getter/setter pair). As such they could be overridden upon extension. At the same time some of the components might be declared as a kind of "class-wide". For these the rules preventing hiding should apply. > In Pascal, a 'with' statement opens up the visibility of the record > components, and if 'with R' is nested within some place where X is > declared, then record component X hides that X. That's bad, and Ichbiah > wisely designed 'use' clauses to not do that bad thing. The trick is to > avoid "preference rules", where one decl takes precedence over another. > But hiding is exactly a preference rule (preferring the inner one over > an outer one, or preferring an outer one over a use-visible one). Alas, but preference rules cannot be avoided. Overriding is just that preference. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de