Newsgroups: comp.lang.smalltalk,comp.object
Path: cantaloupe.srv.cs.cmu.edu!bb3.andrew.cmu.edu!newsfeed.pitt.edu!gatech!swrinde!newsfeed.internetmci.com!howland.reston.ans.net!ix.netcom.com!netcom.com!milod
From: milod@netcom.com (John DiCamillo)
Subject: Re: Polymorphism One More Time
Message-ID: <milodDoA31u.JF4@netcom.com>
Organization: NETCOM On-line Communication Services (408 261-4700 guest)
References: <NEWTNews.13339.826235188.hampton@interramp.com> <3145C961.501F@amd.com> <milodDo6LCM.371@netcom.com> <3146E905.2F45@concentric.net> <314766B6.317D@amd.com>
Date: Thu, 14 Mar 1996 22:13:06 GMT
Lines: 123
Sender: milod@netcom16.netcom.com
Xref: glinda.oz.cs.cmu.edu comp.lang.smalltalk:36004 comp.object:45906

"Paul G. Schaaf, Jr." <paul.schaaf@amd.com> writes:

>References: 
>   "John DiCamillo"<milod@netcom.com>
>   "Alan L. Lovejoy" <alovejoy@concentric.net>
>   "Paul G. Schaaf, Jr." <paul.schaaf@amd.com>  (me)

>Schaaf > [homemade definition of polymorphism]

>DiCamillo > [...] Why are you trying to define a word that already has a 
>DiCamillo > generally accepted definition?  Do you wish to be understood 
>DiCamillo > or is this just wordplay?

>I wish to understand and to be understood.  I was attempting to point out how 
>the provided definitions, "generally accepted" or not, IMHO fall short of 
>adequately describing the concept of polymorphism.  

>Schaaf > BOOCH'S DEFINITION:
>Schaaf > A concept in type theory, according to which a name (such as a 
>Schaaf > variable declaration) may denote objects of many different classes that 
>Schaaf > are related by some common superclass; thus, any object denoted by this 
>Schaaf > name is able to respond to some common set of operations in different 
>Schaaf > ways.

>DiCamillo > This isn't really "Booch's Definition" (is it?) it seems to be
>DiCamillo > more his rephrasing someone else's definition.

>It is.  See:
>   Object-Oriented Analysis And Design, Second Edition.  Grady Booch.  Benjamin 
>Cummings, Redwood City, CA.  1994.  p517

The point I was trying to make, both here and in the previous quoted
paragraph, is that the "definition" you correctly attribute to Booch,
1) wasn't invented by Booch but is a paraphrase of Cardelli's paper, and
2) isn't a very good paraphrase.

Also, I found your "definition" of polymorphism (essentially, 'that
property which results in subsitutability' -- my paraphrase) lacking.
To me, it's as if you had defined water as 'that which makes one wet'.
True, but not very satisfying.

>Lovejoy > Smalltalk is polymorphic because "everything is an object," because 
>Lovejoy > you can assign any object to any slot (variable or message parameter),  
>Lovejoy > because you can send any message to any object, because you can return 
>Lovejoy > any object from any function (method), and because even the 
>Lovejoy > metaobjects are "first class" objects.
> 
>DiCamillo > (Properly speaking, in Smalltalk "all values are objects".  Methods
>DiCamillo > are not objects, or weren't when I programmed in Smalltalk.)

>Methods are objects--or do you mean "messages" (method invocations)?  They are 
>objects, too (but for efficiency reasons, they are only objects when you do 
>something that requires them to be). "Everything is an object" is the often-used 
>Smalltalk catchphrase.  I prefer your "all values are objects" as long as you 
>define "value" as any of {class, metaclass, method, message, integer, float, 
>character, collection, etc.}.  In most implementations, though, slots are not 
>objects.  

Hmmn. I learned Smalltalk several years ago on Smalltalk/V for Windows.
That implementation does not appear to have a class Method, or anything
that appeared to be even roughly similar.  However, I seem to recall that
S/V wasn't exactly according to Hoyle in its metaclass implementation.

>Lovejoy > Properly speaking, things like "inclusion" and "overloading" are 
>Lovejoy > mechanisms or devices that are agonists for polymorphism.  
>Lovejoy > Polymorphism is a property, not a device!
>Lovejoy > Reference: "Polymorphic Programming Languages" [Harland]

>Yes!  Exactly why I take exception to the "generally accepted" definitions.  The 
>concept of polymorphism would exist even if c++ did not.  Defining it as being 
>composed of "inclusion" and/or "overloading" simply because ones favorite 
>language has chosen to break the implementation along those lines obscures the 
>concept beneath.  

I now understand your concern, but I do not agree with your premise.
Cardelli's definition of polymorphism is rooted in type theory -- a
branch of abstract mathematics independent from any particular language.
And the four 'kinds' of polymorphism discussed in his definition,
Inclusion (or subtype), Parametric, Overloading, and Coercion add
richness to the concept (a bit like recognizing that water may also be
a vapor or a solid).

>Schaaf > Also, if one understands the fundamentals of OO, one is in a better 
>Schaaf > position to see what Smalltalk, for instance, has to offer over c++ for 
>Schaaf > a particular task.

>DiCamillo > Garsh, I wonder what the "fundamentals of OO" might be, and how they
>DiCamillo > might differentiate Smalltalk from C++?

>Lovejoy > I think the implication is that polymorphism is the raison d'etre of 
>Lovejoy > OO.

>Exactly.  

>DiCamillo > Hmmn.  I don't quite agree with that.  Reusability and 
>DiCamillo > maintainability are the motivations for OOPLs, as is improved 
>DiCamillo > modeling of the application domain.  Polymorphism is a powerful tool 
>DiCamillo > for achieving these goals, as you state below.

>I see that as wordplay.  Without polymorphism one has _structured_ programming 
>(since inheritance is simply a convenience). 

Actually, based on Cardelli's definition and *yours*, polymorphism
can also be a component of structured programming, through overloading
and coercion, and parametricity.  Only inclusion polymorphism is the
hallmark of OOP.

>I believe the statement of mine to which you are referring is: "If one 
>recognizes the fundamental concept underneath, the compromises made by c++ 
>become visible, and Smalltalk is more easily recognized for what it is--small 
>and beautiful."

Yes. I think that by ignoring the differences between the many kinds
of polymorphism (in particular, the fact that all four lead to a 
different kind of substitutability, even in non-OOPLs), it is you who
is ignoring the "fundamental concept underneath".  Thus, I found your
assertion hollow.

-- 
    ciao,
    milo
================================================================
    John DiCamillo                         Fiery the Angels Fell 
    milod@netcom.com       Deep thunder rode around their shores
