Re: Polymorphism vs. Overloading

strohm@mksol.dseg.ti.com (john r strohm)
Fri, 28 Oct 1994 16:49:51 GMT

          From comp.compilers

Related articles
[2 earlier articles]
Re: Polymorphism vs. overloading sakkinen@jyu.fi (1990-09-14)
Polymorphism vs. Overloading gdevivo@conicit.ve (1994-10-22)
Re: Polymorphism vs. Overloading jhallen@world.std.com (1994-10-22)
Polymorphism vs. Overloading nandu@cs.clemson.edu (1994-10-27)
Re: Polymorphism vs. Overloading norman@flaubert.bellcore.com (1994-10-24)
Re: Polymorphism vs. Overloading ichudov@wiltel.com (1994-10-28)
Re: Polymorphism vs. Overloading strohm@mksol.dseg.ti.com (1994-10-28)
Re: Polymorphism vs. Overloading ryer@dsd.camb.inmet.com (1994-10-28)
Re: Polymorphism vs. Overloading mac@coos.dartmouth.edu (1994-10-25)
Re: Polymorphism vs. Overloading joe@sanskrit.ho.att.com (1994-10-31)
Re: Polymorphism vs. Overloading geld@cs.sun.ac.za (1994-10-31)
Re: Polymorphism vs. Overloading ram@cs.cmu.edu (Rob MacLachlan) (1994-10-25)
Re: Polymorphism vs. Overloading billk@cs.ukans.edu (1994-10-31)
[22 later articles]
| List of all articles for this month |
Newsgroups: comp.compilers
From: strohm@mksol.dseg.ti.com (john r strohm)
Keywords: polymorphism
Organization: Texas Instruments, Inc
References: 94-10-144
Date: Fri, 28 Oct 1994 16:49:51 GMT

In a recent message, gdevivo@conicit.ve (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:


        this->baz(some_random_argument)


and let the runtime sort out the actual type of 'this' and hence which
derived 'baz' method to call.
--


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.