Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!csd4.milw.wisc.edu!uxc!uxc.cso.uiuc.edu!m.cs.uiuc.edu!p.cs.uiuc.edu!johnson From: johnson@p.cs.uiuc.edu Newsgroups: comp.lang.smalltalk Subject: Re: Polymorphism Message-ID: <80500053@p.cs.uiuc.edu> Date: 22 Apr 89 03:14:00 GMT References: <5957@pdn.paradyne.com> Lines: 36 Nf-ID: #R:pdn.paradyne.com:5957:p.cs.uiuc.edu:80500053:000:1951 Nf-From: p.cs.uiuc.edu!johnson Apr 21 22:14:00 1989 Alan, I like what you say, but I don't like your definition of polymorphism. "Full polymorphism means that any component or aspect of a program, program component or programming language must behave as a value." Surely you don't mean that polymorphic languages require that syntax and types are values, but they are both aspects of a program. What about the run-time stack? Name bindings and scopes are not first class objects in any common language. There are times when it would handy if they were. A polymorphic language is one in which procedures can be polymorphic, i.e. can take arguments of many different types. Since the type of a procedure depends on the types of its arguments, this means that the procedure has many types. "Polymorphic" means "many shapes", which I guess is as close to "many types" as Greek is going to get. Object-oriented languages get their polymorphism from the late-binding of message sending. A procedure only cares about the messages that its arguments understand, not which class they are in. What you are calling polymorphism seems to be trying to make everything a procedure call. Smalltalk implements if statements and array accesses with procedure calls, and the user can redefine them or can define a new class with the same operations (this is actually not true, since the compiler cheats on ifTrue: and ifFalse:). Polymorphism combined with making everything a procedure call makes it easy to change a system without breaking it. Polymorphism does not assume that all values have a common set of abilities, just all the values that the procedure will get as arguments. Thus, a summation routine can work with any collection of numbers, but won't work with a collection of windows. It is still polymorphic. There are a number of ways to implement polymorphism, and several varieties of polymorphism. Object-oriented programming provides one of the most useful and versatile. Ralph Johnson