|[2 earlier articles]|
|Re: Polymorphism vs. overloading firstname.lastname@example.org (1990-09-14)|
|Polymorphism vs. Overloading email@example.com (1994-10-22)|
|Re: Polymorphism vs. Overloading firstname.lastname@example.org (1994-10-22)|
|Polymorphism vs. Overloading email@example.com (1994-10-27)|
|Re: Polymorphism vs. Overloading firstname.lastname@example.org (1994-10-24)|
|Re: Polymorphism vs. Overloading email@example.com (1994-10-28)|
|Re: Polymorphism vs. Overloading firstname.lastname@example.org (1994-10-28)|
|Re: Polymorphism vs. Overloading email@example.com (1994-10-28)|
|Re: Polymorphism vs. Overloading firstname.lastname@example.org (1994-10-25)|
|Re: Polymorphism vs. Overloading email@example.com (1994-10-31)|
|Re: Polymorphism vs. Overloading firstname.lastname@example.org (1994-10-31)|
|Re: Polymorphism vs. Overloading email@example.com (Rob MacLachlan) (1994-10-25)|
|Re: Polymorphism vs. Overloading firstname.lastname@example.org (1994-10-31)|
|[22 later articles]|
|From:||email@example.com (john r strohm)|
|Organization:||Texas Instruments, Inc|
|Date:||Fri, 28 Oct 1994 16:49:51 GMT|
In a recent message, firstname.lastname@example.org (Gabriela O. de Vivo) wrote:
>Now, I wonder if some of you could help me by stating more precisely (and
>rigourosly) the exact nature of the difference. I am not looking for a long
>and very-formal dissertation. Few (specific and direct) arguments will be
>OK (and very welcome!!).
Well, basically, a "procedure" typically has a name, an argument signature
(a list of argument name/argument type pairs), and a body.
When you are looking at an overloaded procedure, you will see the same
name and different argument signatures.
When you are looking at a polymorphic procedure, you will see the same
name AND the SAME argument signatures. *SOMETHING* in the language
runtime exists to determine which of the various candidate bodies is the
correct one to be executed for any given invocation. In the case of C++,
that something is the (invisible) pointer to the object method table.
In the case of Oberon, that something is the VISIBLE object handler record
field. (See Reiser's book on Oberon for more details.)
If, for a particular procedure name (or method name) "foo" it can be
uniquely be determined which of several candidate bodies to execute AT
COMPILE TIME OR LINK TIME, then "foo" is overloaded. If the determination
CANNOT be made until run time, then "foo" is polymorphic, because the exact
same call site, executing the exact same machine instructions, may invoke
DIFFERENT bodies each time.
I don't have C++ syntax down well enough. The idea is of a base class, with
several derived classes, a method in the base class (or a friend function)
that has to call a virtual method in the derived classes. The method will
utter something like:
and let the runtime sort out the actual type of 'this' and hence which
derived 'baz' method to call.
Return to the
Search the comp.compilers archives again.