comp.lang.ada
 help / color / mirror / Atom feed
From: schmid@alta.ide.com (Stephen Schmid)
Subject: Re: "use" clauses and Ada 95 OOP
Date: 1996/07/22
Date: 1996-07-22T00:00:00+00:00	[thread overview]
Message-ID: <SCHMID.96Jul22104727@alta.ide.com> (raw)
In-Reply-To: 31EF9D30.7A0@csehp3.mdc.com



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.  




  reply	other threads:[~1996-07-22  0:00 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1996-07-17  0:00 "use" clauses and Ada 95 OOP Mitch Gart
1996-07-19  0:00 ` Robert I. Eachus
1996-07-23  0:00   ` Robert I. Eachus
1996-07-25  0:00     ` JamesS1889
1996-07-23  0:00   ` JamesS1889
1996-07-23  0:00     ` Robert Dewar
1996-07-24  0:00     ` Robert I. Eachus
1996-07-24  0:00   ` Jon S Anthony
1996-07-19  0:00 ` Jon S Anthony
1996-07-19  0:00 ` James A. Squire
1996-07-22  0:00   ` Stephen Schmid [this message]
1996-07-23  0:00     ` Mitch Gart
1996-07-23  0:00       ` Robert A Duff
1996-07-23  0:00       ` Robert Dewar
1996-07-25  0:00         ` JamesS1889
1996-07-26  0:00           ` Robert A Duff
1996-07-23  0:00       ` Kevin J. Weise
1996-07-23  0:00       ` Kevin J. Weise
1996-07-23  0:00         ` JamesS1889
1996-07-23  0:00     ` JamesS1889
1996-07-23  0:00     ` Laurent Guerby
1996-07-23  0:00       ` Robert A Duff
1996-07-23  0:00     ` JamesS1889
1996-07-24  0:00     ` Jon S Anthony
1996-07-24  0:00     ` Jon S Anthony
1996-07-20  0:00 ` James A. Squire
1996-07-21  0:00   ` Robert A Duff
1996-07-22  0:00 ` Jon S Anthony
1996-07-23  0:00 ` Jon S Anthony
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox