Re: Polymorphism vs. Overloading

sofkam@rpi.edu (Michael D Sofka)
Mon, 31 Oct 1994 22:26:14 GMT

          From comp.compilers

Related articles
[11 earlier articles]
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)
Re: Polymorphism vs. Overloading Mike.Chapman@muc.de (Mike Chapman) (1994-10-31)
Re: Polymorphism vs. Overloading jsm@id.dth.dk (1994-10-31)
Re: Polymorphism vs. Overloading sofkam@rpi.edu (1994-10-31)
Re: Polymorphism vs. Overloading andand@csd.uu.se (1994-10-26)
Re: Polymorphism vs. Overloading dekker@dutiag.twi.tudelft.nl (1994-10-31)
Re: Polymorphism vs. Overloading danhicks@aol.com (1994-10-31)
Re: Polymorphism vs. Overloading odersky@ira.uka.de (Martin Odersky) (1994-10-31)
Re: Polymorphism vs. Overloading bevan@cs.man.ac.uk (1994-10-27)
Re: Polymorphism vs. Overloading pjj@cs.man.ac.uk (1994-10-28)
[13 later articles]
| List of all articles for this month |
Newsgroups: comp.compilers
From: sofkam@rpi.edu (Michael D Sofka)
Keywords: polymorphism
Organization: Rensselaer Polytechnic Institute, Troy NY, USA
References: 94-10-144 94-10-154
Date: Mon, 31 Oct 1994 22:26:14 GMT

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 doesn't sound correct. A polymorphic function can take an argument
of a derived type. That is, class A is derived from class B, so any
function that can call class B, can also call class A. For an overloaded
function, a new operator must be defined. The two are similar in that
polymorphism is an automatic form of overloading, but overloading can
be used in many cases where it would be impossible for the compiler to
figure out what should be done.


That's not to say that a language could not be defined in which polymorphism
and overloading are nearly identical. C++ is close since functions,
and overloaded operators are very close.


Mike
--
Michael D. Sofka sofkam@rpi.edu
ITS Systems Programmer
Rensselaer Polytechnic Institute, Troy, NY.
--


Post a followup to this message

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