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: schmid@alta.ide.com (Stephen Schmid) Subject: Re: "use" clauses and Ada 95 OOP Date: 1996/07/22 Message-ID: #1/1 X-Deja-AN: 169543412 references: <31EF9D30.7A0@csehp3.mdc.com> organization: Interactive Development Environments newsgroups: comp.lang.ada Date: 1996-07-22T00:00:00+00:00 List-Id: Mitch Gart wrote: > > > 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. > The above call in C++ does not mean that the function associated with the class X will get called at runtime. If x is a reference to a class, and func is a virtual function, then x.func will 'dispatch' (to use an Ada term) to the function corresponding to whatever class x happens to refer to at runtime, which could be x or any subclass of x, so the situation is similar to that which occurs in Ada. > > In Ada 95 OOP we can have the situation where a call > > > > pkg1.func(x) > > > > dispatches at runtime to > > > > pkg2.func(x) > > > > It seems to me that this notation is misleading because a reader might > > think that the function in pkg1 will be executed. > > I don't think this is misleading, and I would argue in favor of not using the use clause. With the use clause, the reader has no clue as to which function is being called without checking the context clauses, and there is greater opportunity for error. You are giving the reader _less_ information, which cannot be helpful. Including the package name gives the reader a starting point to determine what functions may be called at runtime. In a language with run-time dispatching, that is the most that you can do.