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.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,ad62d6b425bebfec X-Google-Attributes: gid103376,public From: "James A. Squire" Subject: Re: "use" clauses and Ada 95 OOP Date: 1996/07/19 Message-ID: <31EF9D30.7A0@csehp3.mdc.com>#1/1 X-Deja-AN: 168866234 sender: Ada programming language references: comments: Gated by NETNEWS@AUVM.AMERICAN.EDU content-type: text/plain; charset=us-ascii organization: MDA Avionics Tools & Processes mime-version: 1.0 newsgroups: comp.lang.ada x-mailer: Mozilla 2.01 (X11; I; HP-UX A.09.01 9000/715) Date: 1996-07-19T00:00:00+00:00 List-Id: Mitch Gart wrote: > In Ada 95 OOP we can have the situation where a call > > pkg1.func(x) > > dispatches at runtime to > > pkg2.func(x) > > because x is a classwide tagged type whose base type is in pkg1 but whose > runtime tag says it's in fact a derived type in pkg2. > > It seems to me that this notation is misleading because a reader might > think that the function in pkg1 will be executed. > > Therefore with tagged types I have adopted the style of always using > "use" clauses and writing the call > > func(x); > > in the source code. This seems less misleading to me. I never used to > use "use" clauses in Ada 83 but I now use them a lot in Ada 95 when > calling dispatching operations. Hmm... this sounds familiar to me... amazingly like a query I brought up a while back when I apparently didn't understand the underlying semantics of the dispatching call. > Have other people adopted this style? Comments? People who have written > coding standards which say "don't use 'use' clauses", do you think this > rule is still a good idea with Ada 95 dispatching? Well, we qualify under your third question here. To me the problem with the use clause is that it is tempting to take advantage of in unintended ways, which are hard to check for in code reviews. Your suggestion doesn't change that, as compelling as the case probably is. Of course, it is perhaps just as hard to enforce commentary on a dispatching call to alert the maintainer that a routine in pkg2 might be called, so .... interesting dilemma. > To me the C++/Java syntax > > x.func > > seems clearer than the Ada syntax in this case because what is being > called is the function that is associated with X at runtime, rather than > the function that comes from a given package. Indeed, that is a drawback that was mentioned in our group by someone who is familiar with C++. I can't argue with it at all. -- James Squire mailto:ja_squire@csehp3.mdc.com MDA Avionics Tools & Processes McDonnell Douglas Aerospace http://www.mdc.com/ Opinions expressed here are my own and NOT my company's "Nice shark...pretty shark..." -- Londo, "The Gathering"