[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: What's so cool about Scheme?



> Semantic clarification: What are you referring to by "inclusional"
polymorphism?

I can think of three categories of polymorphism (I came across this
classification years ago, in a book on something object-oriented, but the
details escape me):

 - parametric (C++ templates, ML/Haskell lists)
 - inclusional (supertypes, subtypes, inheritance)
 - ad-hoc (overloaded functions where arguments do not share the same types
e.g. using '+' for addition and string concatenation)

I came to the conclusion inclusional polymorphism typifies the
object-oriented style of programming. Some languages support all 3 types
(C++), some just support parametric (ML), and some just inclusional (Java,
although they've recently added parametric).

Inclusional polymorphism is simply the case where when an object of a given
type is expected, an object that is a sub-type of the expected type may also
be used. Kinda obvious, but there you go...

I'm not sure what the relationship is between ad-hoc polymorphism and the
other types. For example, Haskell doesn't allow ad-hoc polymorphism in the
sense described above, but is does have a system for defining overloaded
operators. However, all instances of an overloaded function share a common
supertype (e.g. the arithmetic operators are defined over a variety of
concrete numeric types, all of which are subtypes of the Num class). 


> polymorphism is a necessary addition once you can create types and type
hierarchies

Type hierarchies tend to be found in languages that provide inheritance, and
use inheritance to create subtypes. Most OO-languages use inheritance to
create subtypes, and some people have trouble making the distinction between
inheritance and subtyping. As a counter-example, Emerald is a language that
supports inclusional polymorphism but does not have inheritance.


> I think of OO as being the ability to provide user-defined types with
invariants

I'm not sure what "invariants" are (but I do know that use-defined types
are). Is it possible to have "user-defined types with invariants" in a
language that would not be considered object-oriented (Modula, Pascal, C,
ML)?


-----Original Message-----
From: Mike Newhall [mailto:mike@newhall.net]
Sent: 03 June 2003 15:51
To: Bayley, Alistair
Cc: ll1-discuss@ai.mit.edu
Subject: RE: What's so cool about Scheme?


>procedural languages. That is, the thing that determines whether or not a
>language is object-oriented is: does it support inclusional polymorphism?

	Semantic clarification: What are you referring to by "inclusional"
polymorphism?

	I think of OO as being the ability to provide user-defined types
with invariants; polymorphism is a necessary addition once you can create
types and type hierarchies.


*****************************************************************
The information in this email and in any attachments is 
confidential and intended solely for the attention and use 
of the named addressee(s). This information may be 
subject to legal professional or other privilege or may 
otherwise be protected by work product immunity or other 
legal rules.  It must not be disclosed to any person without 
our authority.

If you are not the intended recipient, or a person 
responsible for delivering it to the intended recipient, you 
are not authorised to and must not disclose, copy, 
distribute, or retain this message or any part of it.
*****************************************************************