|[23 earlier articles]|
|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-29)|
|Re: Polymorphism vs. Overloading email@example.com (1994-10-29)|
|Re: Polymorphism vs. Overloading firstname.lastname@example.org (1994-11-01)|
|Re: Polymorphism vs. Overloading email@example.com (kanze) (1994-11-01)|
|Re: Polymorphism vs. Overloading davidm@Rational.COM (1994-10-31)|
|Re: Polymorphism vs. Overloading firstname.lastname@example.org (1994-11-01)|
|Re: Polymorphism vs. Overloading email@example.com (1994-11-01)|
|Re: Polymorphism vs. Overloading firstname.lastname@example.org (1994-11-02)|
|Re: Polymorphism vs. Overloading bimbart@CS.kuleuven.ac.be (Bart Demoen) (1994-11-02)|
|Re: Polymorphism vs. Overloading email@example.com (1994-11-01)|
|Re: Polymorphism vs. Overloading firstname.lastname@example.org (1994-11-09)|
|[1 later articles]|
|From:||davidm@Rational.COM (David Moore)|
|Organization:||Rational Software Corporation|
|Date:||Mon, 31 Oct 1994 21:54:55 GMT|
email@example.com (Mike Ryer) writes:
>Overloading happens at compilation time -- the compiler decides which function
>to invoke based on statically-determined types of the operands.
>Polymorphism may not happen until runtime -- the compiler generates code that
>fans out based on the runtime value of a tag.
This is the answer I would have given too - until the question was
asked by someone who almost certainly already knew this answer.
If you instead try to define the difference in terms of the semantics
of the language instead of how the language is implemented, it is
My suggestion would be that polymorphic functions impose more structure
than overloaded functions.
Let's just consider the case of functions with the same parameter (and result)
profiles - this is the interesting case.
For polymorphic functions, there is a semi-lattice on the functions induced
by the semi-lattice on the types. This semi-lattice is just the derivation
tree - if type t2 is derived (directly or indirectly) from type t1 then
t1<t2. If we have function f:t1 and a function f:t2, we can say
One can probably extend this to multiple parameters, although many
languages only support polymorphism in one parameter.
For overloaded functions, no such order exists.
Quite clearly, in a language like C++, a given identifier can be
both overloaded and polymorphic, because two types need not be in a
common semi-lattice, so there can be some polymorphic definitions and
some overloaded definitions for an identifier.
However, if we accept this definition, then in a language where all types
are derived from some basic type (Smalltalk?) there is no such thing
as overloading (of functions with the same profiles) - only polymorphism.
Return to the
Search the comp.compilers archives again.