Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!ames!indri!lll-winken!uunet!mcvax!ukc!etive!lfcs!db From: db@lfcs.ed.ac.uk (Dave Berry) Newsgroups: comp.lang.c++ Subject: Re: Polymorphism Message-ID: <1898@etive.ed.ac.uk> Date: 2 May 89 13:16:21 GMT References: <5957@pdn.paradyne.com> <2841@crete.cs.glasgow.ac.uk> <3150@kalliope.rice.edu> 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: 35 In article <3150@kalliope.rice.edu> boehm@flora.rice.edu (Hans Boehm) writes: > There is some legitimate debate whether ML (without the recently added > module system) should really be considered polymorphic. ML-style > polymorphism (like Ada generics) can always be replaced by macro expansion. > (Unlike in Ada, this is not the usual implementation strategy. Also unlike > Ada, polymorphic expressions have a type that can be written down.) I'm having trouble understanding much of this debate. In particular, how can ML style polymorphism be replaced by macro expansion? Also, do you consider the module system to be polymorphic? (I don't. In fact it's much more like ADA than the core language. It provides type parameterisation rather than polymorphism.) 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. 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. 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. Could Hans or Alan explain their points further? "See, this is why I got off drugs. Who can tell the difference anymore?" Dave Berry, Laboratory for Foundations of Computer Science, Edinburgh. db%lfcs.ed.ac.uk@nsfnet-relay.ac.uk !mcvax!ukc!lfcs!db