Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!ukma!xanth!lll-winken!uunet!pdn!rnms1!alan From: alan@rnms1.paradyne.com (Alan Lovejoy) Newsgroups: comp.lang.smalltalk Subject: Re: Polymorphism Message-ID: <5974@pdn.paradyne.com> Date: 23 Apr 89 18:45:59 GMT References: <5957@pdn.paradyne.com> <80500053@p.cs.uiuc.edu> Sender: news@pdn.paradyne.com Reply-To: alan@rnms1.paradyne.com (Alan Lovejoy) Organization: AT&T Paradyne, Largo, Florida Lines: 71 In article <80500053@p.cs.uiuc.edu> johnson@p.cs.uiuc.edu writes: > >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. Most commentators on my posting seem to be consistently misinterpreting what I meant. The definition I gave is what I consider to be the ideal, the ultimate, the most extreme example, the transitive closure of polymorphism. Polymorphism is not a binary property which is either present or absent. It is a direction in a continuum. I tried to define a point way out on the polymorphic side of that continuum. It would be interesting to see whether I succeeded. Do you think I left anything out? >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. Polymorphism is not restricted to functions. A data structure whose elements can be of any type is also polymorphic (e.g., arrays in Smalltalk, lists in LISP). Polymorphic means "many forms." A "form" in greek is a more general concept than it is in english. The idea is that "many (transitively: all) things can be forms (instances of a type), and any object can interact with many (all) other things." A type might be defined as the definition of the form and behavior of its instances. >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. Presisely. Conceptually, inspecting the value of a variable, evaluating an expression and evaluating a function are the same thing. Assignment to a variable is equivalent to a procedure call with side effects. >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. No and yes. Values which cannot be passed as parameters, or which must be passed to and/or accepted by a procedure using different syntax, violate polymorphism. I did not say that all values must share all functions, only that they must share certain functions, such as how to be passed as an argument or inserted into a data structure. All numbers should understand "+." All collections should understand "size." All objects should understand "value" (which is usually sent only implicitly in Smalltalk, just as most languages no longer require the operator "CALL" in front of subroutines). So yes, the summation routine that can't handle BitBlt instances may still be quite polymorphic. 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.