From: Nick Rothwell
Subject: Re: Polymorphism
Date: 
Message-ID: <1810@etive.ed.ac.uk>
I've cut down the Followup distribution of this, to stop it going out to the
entire universe; I think that general discussions of language issues belong
in comp.lang.misc...?

In article <····@pdn.paradyne.com> ····@rnms1.paradyne.com (Alan Lovejoy) writes:
>1. "Polymorphic Programming Languages -- Design and Implementation" -- 1984
>   David M. Harland, B.Sc., M.Sc., Ph.D., University Of Glasgow
>   Halsted Press: a division of John Wiley & Sons
>   -- MUST READING --
>

The mathematical basis for polymorphic type systems comes from Robinson's
article on unification in the JACM, from around '67 (sorry, can't remember
the title). From here, there's Milner's work, the LCF system, and of course
(fanfare:) ML.

>-- Definition Of Polymorphism --
>   
>Full polymorphism means that any component or aspect of a program, program 
>component or programming language must behave as a value.  Any and all
>values must be subject to inspection, modification, storage in memory,
>usage as a component part of some composite value, usage as a paremeter, 
>usage as an operand in an expression, being computed as the result of
>evaluating an expression or function, and (re)definition of its form, structure,
>content or name.  The protocol for invoking these common operations must be 
>the same for all values, regardless of type.

People might disagree about the extent of "full" polymorphism. ML is
certainly polymorphic, although you can't "inspect" all values (they may
be abstract, or function objects). "modification" is only allowed on
objects created specially for the purpose: how do you modify a function?
"Storage in memory" - doesn't make sense for higher-order garbage collected
languages. "(re)definition of its form" I don't understand...

>To say the same thing more concretely:  numbers, characters, data types,
>procedures, variables, addresses, blocks, execution contexts, name bindings, 
>scopes, processes and the number of bits in an integer must all be "first 
>class objects."

...although a lot of these things (addresses? blocks?) don't exist in some
languages. And I don't see that you want to allow the user to alter absolutely
everything ("hey, let's change the number of bits in a word from being 32
to being yellow...").
   I presume that this is David Harland's definition of polymorphism...? His
approach is to provide this rich model, where everything goes, with
sophisticated hardware support. But, this is a specific approach, and shouldn't
be taken to imply that polymorphism encapsulates everything in this approach.

>-- Definition of Abstraction --
>
>Abstraction is the process of discovering and/or expressing what is INVARIANT,
>constant and organic in a system by taking out, leaving out or not mentioning 
>that which is changing, temporary or accidental.

Isn't that a rather strange way of putting it? I view abstraction as a process
of distinguishing a system's interface from its implementation.

>The point is that polymorphism enhances the power of abstraction mechanisms.
>Lack of polymorphism cripples abstraction.

Absolutely. In conventional languages, you have to be concerned with the
form data structures take (is it a record? an address of a record? do I
have to garbage collect it? etc. etc.). Polymorphism does away with this,
but the price you pay is that polymorphism requires support (garbage collected
store, special hardware, etc. etc.). A price I'm quite willing to pay,
actually... Now, where's that ML session...?

>Alan Lovejoy; ····@pdn; 813-530-2211; AT&T Paradyne: 8550 Ulmerton, Largo, FL.

		Nick.
--
Nick Rothwell,	Laboratory for Foundations of Computer Science, Edinburgh.
		····@lfcs.ed.ac.uk    <Atlantic Ocean>!mcvax!ukc!lfcs!nick
~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~
...while the builders of the cages sleep with bullets, bars and stone,
they do not see your road to freedom that you build with flesh and bone.