Xref: utzoo comp.lang.c++:3210 comp.lang.misc:2899 Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!cs.utexas.edu!uunet!mcvax!ukc!etive!lfcs!db From: db@lfcs.ed.ac.uk (Dave Berry) Newsgroups: comp.lang.c++,comp.lang.misc Subject: Re: Polymorphism Message-ID: <1943@etive.ed.ac.uk> Date: 5 May 89 19:21:44 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> Sender: news@etive.ed.ac.uk Reply-To: db@lfcs.ed.ac.uk (Dave Berry) Organization: Laboratory for the Foundations of Computer Science, Edinburgh U Lines: 46 In article <6057@pdn.paradyne.com> alan@oz.paradyne.com (Alan Lovejoy) writes: >>My definition of a polymorphic function is one that can be applied >>to objects of more than one type. > >This is the result of type polymorphism when applied to functions. >An array which can accept values of any type as elements is the result >of type polymorphism when applied to data structures. True. I usually think of data constructors as functions too. This comes of working on the ML project. >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.) >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? >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. Providing that the type system can specify the type of the function (if you're using a type system). "You never smile, you know it wouldn't look right. 'Cause your dentures glow in ultra-violet light..." Dave Berry, Laboratory for Foundations db%lfcs.ed.ac.uk@nsfnet-relay.ac.uk of Computer Science, Edinburgh Uni. !mcvax!ukc!lfcs!db