Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!uwm.edu!cs.utexas.edu!tut.cis.ohio-state.edu!ucbvax!decwrl!shelby!neon!pallas From: pallas@Neon.Stanford.EDU (Joe Pallas) Newsgroups: comp.object Subject: Re: "Ad Hoc Polymorphism" -- I'm Quoting Someone Else Keywords: ad hoc polymorphism, reference to original use Message-ID: <1990Jan9.194423.22908@Neon.Stanford.EDU> Date: 9 Jan 90 19:44:23 GMT References: <646@ajpo.sei.cmu.edu> Organization: Computer Science Department, Stanford University Lines: 39 In article <646@ajpo.sei.cmu.edu> eberard@ajpo.sei.cmu.edu (Edward Berard) writes: >If you recognize this type of polymorphism as having a different name, >and can cite two, or more, earlier references, I will consider using >a different name. (Heck! I'll even take _one_ earlier reference. ;-)) On the contrary, this is exactly the usage that the community at large uses. An excellent reference is Cardelli & Wegner's ``On Understanding Types, Data Abstraction, and Polymorphism'' in Computing Surveys 17:4 (Dec. 1985). They classify polymorphism as either ad hoc (applying to a finite number of unrelated types) or universal (applying to an infinite number of related types). Ad hoc polymorphism includes overloading and coercion. Universal polymorphism is further classified as parametric or inclusion polymorphism. Inclusion polymorphism is the important one for OOP---it's the case in which ``an object can be viewed as belonging to many different classes that need not be disjoint.'' This happens with inheritance: when an X is a Y, function f:X->Z can take parameters of type Y. Ed's article suggested that parametric polymorphism is distinct from what he called ``general polymorphism'' (same code for any type), but Cardelli & Wegner don't make that distinction. They describe both parametric and inclusion polymorphism as using the same code for any type. (Arguments on this point necessarily revolve around the definition of ``same code''. They treat parametric/generic code as ``same'' for different parameters.) Note that a single system can have more than one kind of polymorphism. Most modern languages support both kinds of ad hoc polymorphism (overloading and implicit coercions), at least for built-in arithmetic types. Ada adds parametric polymorphism (generics). C++ adds inclusion polymorphism (derived classes). Eiffel adds both parametric and inclusion polymorphism. I think CLOS generic functions can even be overloaded, parametric, and inclusive all at once. joe