Re: Static typing, polymorphism, inheritance
From: TLOlczyk (olczyk2002_at_yahoo.com)
Date: 11/01/03
- Next message: Topmind: "Re: OO's best feature survey results"
- Previous message: Topmind: "Re: OO's best feature survey results"
- In reply to: Costin Cozianu: "Static typing, polymorphism, inheritance"
- Next in thread: TLOlczyk: "Re: Static typing, polymorphism, inheritance"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Sat, 01 Nov 2003 03:02:38 -0600
On Fri, 31 Oct 2003 13:05:51 -0800, Costin Cozianu
<c_cozianu@hotmail.com> wrote:
>(* or even better, here's a polymorphic list : *)
>let myList= [ new person "Steve" 20 ; new employee "Costin" 20 1001]
>;;
There is a problem here.
myList;;
reveals that myList has type person list.
For the most part employee is treated OK in the list, but if you
add a method to either person or employee you will get errors
with myList.
The problem is not with typing but with the fact that [ ] generates
a homogeneous list. You would have to use an inhomogeneous list,
but I'm not that familiar with the library.
You can still see that there types are treated polymorphically via:
let g_print x s= x#print s;;
g_print x;;
g_print y;;
- Next message: Topmind: "Re: OO's best feature survey results"
- Previous message: Topmind: "Re: OO's best feature survey results"
- In reply to: Costin Cozianu: "Static typing, polymorphism, inheritance"
- Next in thread: TLOlczyk: "Re: Static typing, polymorphism, inheritance"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]