Browse thread
[Caml-list] Restricting Method Overriding/Redefinition in Subclass
[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| From: | skaller <skaller@u...> |
| Subject: | Re: [Caml-list] Restricting Method Overriding/Redefinition in Subclass |
On Wed, 2004-08-18 at 22:04, chris.danx wrote: > Separating subtyping from subclassing is > something I'd read about (in the context of polymorphism and > subclassing) and thought was very useful. You aren't going far enough. Subtyping is a *semantic* notion. Whether a class satisfies the 'is a' relation or not is the issue. In Ocaml, if a class has a type which is not an *Ocaml* subtype of another it probably isn't a subtype semantically *** The converse is not true. Just because Ocaml thinks your class has a subtype of another classes type does NOT mean it actually is a subtype -- you still need to check the methods to make sure the 'is a' property holds. If you override some method and give it an incompatible behaviour you don't have a subtype (you'll just get weird bugs!) *** It is possible to have a class which acts semantically 'as' another but is not ruled by Ocaml as a subtype. A trivial example of this is when you have two methods called 'size' in one class and 'length' in another that do the same job -- but happen to be encoded with distinct names. You'll have to use a wrapper to fix this without invading one of the classes (and then probably breaking something else). -- John Skaller, mailto:skaller@users.sf.net voice: 061-2-9660-0850, snail: PO BOX 401 Glebe NSW 2037 Australia Checkout the Felix programming language http://felix.sf.net ------------------- 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