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

RE: how is polymorphism used?



> 3. The code works with different types, but is just generic, 
> not polymorphic.  A queue would fall under this category.  It 
> might work on any type, but it doesn't do anything different 
> when used with different types.

Using the same algorithm at all types is the essence of parametric
polymorphism.

> My first guess would be that in most (not all) applications 
> there are a few generic utility classes/modules/functions and 
> the rest of the code is pretty tied to certain types, even if 
> the language doesn't force this.  In other words, for most 
> code you could replace it with a statically typed language 
> without really changing much.

Polymorphism and static typing aren't mutually exclusive; ML and 
Haskell use polymorphism and are statically typed.

-- Paul