Re: Polymorphism vs. Overloading

kanze <kanze@lts.sel.alcatel.de>
Tue, 1 Nov 1994 02:46:03 GMT

          From comp.compilers

Related articles
[22 earlier articles]
Re: Polymorphism vs. Overloading bevan@cs.man.ac.uk (1994-10-27)
Re: Polymorphism vs. Overloading pjj@cs.man.ac.uk (1994-10-28)
Re: Polymorphism vs. Overloading jhf@c3serve.c3.lanl.gov (1994-10-28)
Re: Polymorphism vs. Overloading mmcg@bruce.cs.monash.edu.au (1994-10-29)
Re: Polymorphism vs. Overloading hbaker@netcom.com (1994-10-29)
Re: Polymorphism vs. Overloading jhallen@world.std.com (1994-11-01)
Re: Polymorphism vs. Overloading kanze@lts.sel.alcatel.de (kanze) (1994-11-01)
Re: Polymorphism vs. Overloading davidm@Rational.COM (1994-10-31)
Re: Polymorphism vs. Overloading bill@amber.ssd.csd.harris.com (1994-11-01)
Re: Polymorphism vs. Overloading drichter@pygmy.owlnet.rice.edu (1994-11-01)
Re: Polymorphism vs. Overloading bevan@cs.man.ac.uk (1994-11-02)
Re: Polymorphism vs. Overloading bimbart@CS.kuleuven.ac.be (Bart Demoen) (1994-11-02)
Re: Polymorphism vs. Overloading monnier@di.epfl.ch (1994-11-01)
[2 later articles]
| List of all articles for this month |
Newsgroups: comp.compilers
From: kanze <kanze@lts.sel.alcatel.de>
Keywords: polymorphism
Organization: Compilers Central
References: 94-10-144 94-10-154
Date: Tue, 1 Nov 1994 02:46:03 GMT

Gabriela O. de Vivo <gdevivo@conicit.ve> wrote:


>Last week I was invited to join a Thesis (MsC) presentation.
>At some point a question raised about the exact difference between
>Polymorphism and Overloading.


jhallen@world.std.com (Joseph H Allen) writes:
|> The difference is purely syntactical. Calls to overloaded functions look,
|> well, like function calls. Calls to polymorphic functions require a dot or
|> '->' somewhere. Really, that's the only difference. Artificial semantic
|> restrictions placed by certain languages aside, you can always move the
|> identifier or address-expression from the left of the dot into the
|> parenthasis as the first argument to generate an equivelent overloaded
|> function call.


This is not the way I understand it. Basically, overloading is
(usually) resolved by the compiler, at compile time. Polymorphism
must be resolved at run-time; the compiler doesn't know which function
will actually be called.


The presence or absence of a dot or `->' signal only whether the
function called is a member function or a global function. In C++,
only member functions can be polymorphic; this may be the source of
some of the confusion. But this is a restriction of C++ (in common
with a lot of other languages), not of the concept of polymorphism.


Polymorphism (virtual functions in C++) and overloading are orthogonal
concepts: a function can be both polymorphic and overloaded, or just
polymorphic, or just overloaded, or none of the above.
--


James Kanze Tel.: (+33) 88 14 49 00 email: kanze@lts.sel.alcatel.de
GABI Software, Sarl., 8 rue des Francs-Bourgeois, F-67000 Strasbourg, France
--


Post a followup to this message

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