Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!asuvax!ncar!ico!haddock!ima!esegue!compilers-sender From: stt@inmet.inmet.com Newsgroups: comp.compilers Subject: Re: Defining polymorphism vs. overloading Keywords: polymorphism Message-ID: <19400003@inmet> Date: 15 Sep 90 14:32:00 GMT Sender: compilers-sender@esegue.segue.boston.ma.us Reply-To: stt@inmet.inmet.com Organization: Compilers Central Lines: 34 Approved: compilers@esegue.segue.boston.ma.us 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 -- Send compilers articles to compilers@esegue.segue.boston.ma.us {ima | spdcc | world}!esegue. Meta-mail to compilers-request@esegue.