Version française
Home     About     Download     Resources     Contact us    
Browse thread
[Caml-list] Delegation based OO
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Yamagata Yoriyuki <yoriyuki@m...>
Subject: Re: [Caml-list] Delegation based OO
From: Kenneth Knowles <kknowles@berkeley.edu>
Subject: Re: [Caml-list] Delegation based OO
Date: Mon, 22 Mar 2004 16:29:26 -0800

> This is a type error, just as if you override a class method with one of a
> different type:
> 
> # class x = object method y = 3 end;;
> class x : object method y : int end
> # class y = object inherit x method y = 4 end;;
> class y : object method y : int end
> # class z = object inherit x method y = "hello" end;;
> This expression has type string but is here used with type int
> 
> The same strictness could be applied to delegation.

There is a difference.  You cannot hide the method "y" in the class
definition "x". An object can be coerced to a super type, so that it's
type would forget about the method "y", then you override it...

--
Yamagata Yoriyuki

-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners