Re: Defining polymorphism vs. overloading

stt@inmet.inmet.com
15 Sep 90 14:32:00 GMT

          From comp.compilers

Related articles
[13 earlier articles]
Re: Defining polymorphism vs. overloading pardo@cs.washington.edu (1990-09-07)
Re: Defining polymorphism vs. overloading pardo@cs.washington.edu (1990-09-07)
Re: Defining polymorphism vs. overloading mmengel@cuuxb.ATT.COM (1990-09-11)
Re: Defining polymorphism vs. overloading freek@fwi.uva.nl (1990-09-10)
Re: Defining polymorphism vs. overloading pcg@cs.aber.ac.uk (Piercarlo Grandi) (1990-09-13)
Re: Defining polymorphism vs. overloading voss@suna0.cs.uiuc.edu (1990-09-14)
Re: Defining polymorphism vs. overloading stt@inmet.inmet.com (1990-09-15)
Re: Defining polymorphism vs. overloading px@fctunl.rccn.pt (1990-09-20)
Re: Defining polymorphism vs. overloading pcg@compsci.aberystwyth.ac.uk (Piercarlo Grandi) (1990-09-20)
Re: Defining polymorphism vs. overloading chip@soi.com (Chip Morris) (1990-09-15)
| List of all articles for this month |

Newsgroups: comp.compilers
From: stt@inmet.inmet.com
Keywords: polymorphism
Organization: Compilers Central
Date: 15 Sep 90 14:32:00 GMT

Here is my favorite so far:


> - Overloading is the ability to have the same name (symbol) attached
> to different entities (functions, procedures, variables or whatsoever).
>
> - Polymorphism is the ability to have the compiler decide *at runtime*
> which entity to use depending on the runtime type (class or whatever)
> of the contents of variables.
>
> - Generic code is a chunk of code that has the ability of performing
> the same algorithm with more than one type. The actual types may be
> known at runtime (as in Smalltalk) or at compile time (as in Ada).
> . . .
> Joaquim Manuel Soares Baptista, aka px@fctunl.rccn.pt, px@unl.uucp


However, I would revise the definition of polymorphism as follows:


- Polymorphism is the ability to have a single entity (usually a parameter or
a pointer) refer to objects/values of more than one type. Run-time
polymorphism (like C++) allows the dispatch to type-specific code to be made
at run-time. Compile-time polymorphism (like Ada's generics) performs the
"dispatch" to type-specific code at compile-time.


- Generic code is code that manipulates polymorphic parameters/pointers, by
taking advantage of the commonality across the multiple types represented by
them. In most cases, however, it must eventually "dispatch" to type-specific
code.


S. Tucker Taft stt@inmet.inmet.com; uunet!inmet!stt
Intermetrics, Inc.
Cambridge, MA 02138
--


Post a followup to this message

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