Xref: utzoo comp.lang.c++:3242 comp.lang.misc:2921 Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!ames!lll-lcc!lll-winken!uunet!pdn!oz!alan From: alan@oz.nm.paradyne.com (Alan Lovejoy) Newsgroups: comp.lang.c++,comp.lang.misc Subject: Re: Polymorphism Message-ID: <6087@pdn.paradyne.com> Date: 9 May 89 22:02:55 GMT References: <5957@pdn.paradyne.com> <2841@crete.cs.glasgow.ac.uk> <3150@kalliope.rice.edu> <1898@etive.ed.ac.uk> <6057@pdn.paradyne.com> <1943@etive.ed.ac.uk> Sender: news@pdn.paradyne.com Reply-To: alan@oz.paradyne.com (Alan Lovejoy) Organization: AT&T Paradyne, Largo, Florida Lines: 69 In article <1943@etive.ed.ac.uk> db@lfcs.ed.ac.uk (Dave Berry) writes: >In article <6057@pdn.paradyne.com> alan@oz.paradyne.com (Alan Lovejoy) writes: >>An abstraction mechanism which can be used to construct array types of any >>index and/or element type is the result of type polymorphism when applied to >>metaclasses (a metaclass is an abstraction mechanism which constructs types). > >That's an interesting view. The approach taken round here is to use the >idea of dependent function types from type theory (as in Martin-Lo"f >type theory, Calculus of Constructions, etc.) > >It still seems to me that the question of treating everything as a value >is orthogonal to the question of what is polymorphism. (Obviously >the combination makes languages more expressive.) See below. >>My definition of polymorphism had TWO essential components: >> >>1) Value universality >>2) Protocol universality >> >>Overloading is a mechanism for accomplishing protocol universality. > >Is it the only such mechanism that you were thinking of, or were you >also thinking of the mechanism that I call polymorphism? I thought polymorphism was a property, not a mechanism. Could you explain how your conceptualization of polymorphism qualifies as a mechanism? If I say that language X permits functions to accept and produce values of any type, would you say that that language is highly polymorphic? What if langauge X only has two value types: integer and real? For theoretical reasons, it is productive to view all actions that occur in the compilation and/or execution of a program as the result of the evaluation of functions. Hence, the definition of new type should be viewed as a service provided by a compile-time function ("compile-time" in most languages, anyway). The range of definable data types in a language is obviously a function of the polymorphism of the type-creation function. Similarly, the production of values of a type should be viewed as a service provided by an instantiation function. Obviously, the polymorphism of this instantiating function determines what can be a value in a language. This is how my definition of polymorphism can be derived from the definition which you are used to. Values are instances of a type (objects are instances of a class). The requirement for protocol universality is related to the requirement for value universality by this fact, because the existence of the ability, and the protocol, to instantiate integers motivates the existence of the ability to instantiate other types USING THE SAME INSTANTIATION PROTOCOL. By the same reasoning, the ability to define the integer type motivates the ability to define other types USING THE SAME TYPE DEFINITION PROTOCOL. In other words, if types are the result of functions which evaluate to types, then polymorphism demands that the type definition function be able to produce multiple types. Given multiple types, polymorphism demands that the value instantiation function accept many types as an input parameter. From this perspective, functions, even notional ones, that are available to the compiler but not to the programmer, impair polymorphism. Denial of the services of a function is the same thing as prohibiting the use of a type (or its instances). FUNCTIONS ARE VALUES, TOO. Second class functions are second class values. Ask not only what types are in the domain of your functions, but also what functions are defined on your types. 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.