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!news1.google.com!news.maxwell.syr.edu!newsfeed.icl.net!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> <88zllqj1min5$.fqqxis9i327d$.dlg@40tude.net> Date: Thu, 17 Mar 2005 11:22:11 +0100 Message-ID: <18e9a92kz25wu$.8b965bel5vef$.dlg@40tude.net> NNTP-Posting-Date: 17 Mar 2005 11:18:39 MET NNTP-Posting-Host: 579e42b6.newsread4.arcor-online.net X-Trace: DXC=RMK44J<0Z_bIeeCiY5g2Vc:ejgIfPPlddjW\KbG]kaMhGSi?jHD8GO`VPa5DoUUEKn[6LHn;2LCVn7enW;^6ZC`d<=9bOTW=MNn X-Complaints-To: abuse@arcor.de Xref: g2news1.google.com comp.lang.ada:9539 Date: 2005-03-17T11:18:39+01:00 List-Id: On 16 Mar 2005 15:41:55 -0500, Robert A Duff wrote: > "Dmitry A. Kazakov" writes: > >> On 12 Mar 2005 16:59:26 -0500, Robert A Duff wrote: >> >>> "Dmitry A. Kazakov" writes: >> >> 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. > > I see your point, but I think that can be dealt with by having good > error messages. In any language that allows overloading, there are > going to potential ambiguities, and when they happen, I expect more from > the compiler than just "error: I'm confused". > > In Ada, if you have: > > procedure Foo(X: Integer); > procedure Foo(Y: Integer); > > in the same package, it's illegal. But if they're in two different > packages, both use-visible, then it's legal, and you can call them > using named notation: Foo(X => 1) vs. Foo(Y => 1). That seems odd > to me. Should that use clause be illegal? Yes, at least "transitive use" should be. Otherwise, overloading of two Foo's should be allowed (which would be bad). Good error messages might be OK from the perspective of a package user. But from the package designer's one it is not enough, when he wants to make his packages "use"-friendly, especially "transitive use"-friendly. > ... And don't make the > overload-resolution rules too "smart", so they make many things > ambiguous (and therefore illegal). I definitely agree with this. >> Alas, but preference rules cannot be avoided. Overriding is just that >> preference. > > I don't see why. Overriding is different -- the old thing goes away. > It's explicit, so it's OK. Presently it is not explicit. Syntactically overriding is undistinguishable from declaring a new operation. This is IMO bad. It should be sort of: procedure Override (X : Object) is ????; -- Overriding intended, fails if base types have no primitive Override procedure Override (X : Object); -- Overloading intended, fails if it hides any other Override > If we had this language: > > declare > I : Integer; > begin > hide I; <<<<<<<<<<<<<<<<<<<<<<<< > for I in A'Range loop > A (I) := 0; > end loop; > > then the hiding would be OK, IMHO. I agree with the idea, but I think that hiding should appear in a declarative part. Less probably it should also qualify the thing being hidden (like renames does): declare I : Integer; begin declare I : Integer is null; -- Know me, if you want to get rid of me! begin for I in A'Range loop A (I) := 0; end loop; -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de