Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!ames!lll-winken!uunet!pdn!oz!alan From: alan@oz.nm.paradyne.com (Alan Lovejoy) Newsgroups: comp.lang.c++ Subject: Re: Polymorphism Message-ID: <6057@pdn.paradyne.com> Date: 3 May 89 02:51:41 GMT References: <5957@pdn.paradyne.com> <2841@crete.cs.glasgow.ac.uk> <3150@kalliope.rice.edu> <1898@etive.ed.ac.uk> Sender: news@pdn.paradyne.com Reply-To: alan@oz.paradyne.com (Alan Lovejoy) Organization: AT&T Paradyne, Largo, Florida Lines: 53 >My definition of a polymorphic function is one that can be applied >to objects of more than one type. Examples are the universal polymorphism >of ML and the bounded polymorphism of typed systems with inheritance. This is the result of type polymorphism when applied to functions. An array which can accept values of any type as elements (e.g., the first element is an integer, the second element is a BitBlt, etc.) is the result of type polymorphism when applied to data structures. An abstraction mechanism for constructing array types, which can be used to construct array types of any index and/or element type (e.g., Pascal has an array type constructor which can construct array types of any element type and any *ordinal* index type: "ARRAY OF ") is the result of type polymorphism when applied to metaclasses (a metaclass is an abstraction mechanism which constructs classes (types)). Pascal's array-type constructor can be thought of as a function which returns array types given two types as arguments. Notice that this is one of the only two ways in which types act as values in Pascal (the other is when a type is an argument to the SIZEOF pseudofunction). >A similar feature is overloading, a.k.a. ad-hoc polymorphism. This is >a polymorphism of a name rather than a function itself; a name may refer >to functions of more than one type, depending on the types of its arguments. >Examples include static overloading of C++, Ada etc., and dynamic overloading >of C++ virtual functions, Eiffel etc. Overloading does not make a function polymorphic. It may enable the definition of polymorphic abstractions and/or abstraction mechanisms, however. A function which, among other things, invokes the "Print" function on its argument will be more polymorphic if "Print" has been overloaded for many value types. >I don't see how "treating everything as a value" affects this definition. If >everything can be treated as a value then universal polymorphism will apply >to everything, if not it will only apply to values (and not types). But this >seems to be a question of defining the "type of a type", rather than a >definition of polymorphism. My definition of polymorphism had TWO essential components: 1) Value universality 2) Protocol universality Overloading is a mechanism for accomplishing protocol universality. >Could Hans or Alan explain their points further? Alan Lovejoy; alan@pdn; 813-530-2211; AT&T Paradyne: 8550 Ulmerton, Largo, FL. Disclaimer: I do not speak for AT&T Paradyne. They do not speak for me. _________________________Design Flaws Travel In Herds_________________________ Motto: If nanomachines will be able to reconstruct you, YOU AREN'T DEAD YET.