From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id AAA28475; Thu, 19 Aug 2004 00:21:52 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id AAA27930 for ; Thu, 19 Aug 2004 00:21:51 +0200 (MET DST) Received: from smtp1.adl2.internode.on.net (smtp1.adl2.internode.on.net [203.16.214.181]) by nez-perce.inria.fr (8.12.10/8.12.10) with ESMTP id i7IMLmmL007280 for ; Thu, 19 Aug 2004 00:21:49 +0200 Received: from [192.168.1.200] (ppp211-206.lns2.syd3.internode.on.net [203.122.211.206]) by smtp1.adl2.internode.on.net (8.12.9/8.12.9) with ESMTP id i7IMLT4Y094645; Thu, 19 Aug 2004 07:51:30 +0930 (CST) Subject: Re: [Caml-list] Restricting Method Overriding/Redefinition in Subclass From: skaller Reply-To: skaller@users.sourceforge.net To: "chris.danx" Cc: John Prevost , Caml Mailing List In-Reply-To: <412345DC.5050206@ntlworld.com> References: <411D56EC.2070301@ntlworld.com> <1092469137.29139.564.camel@pelican.wigram> <412345DC.5050206@ntlworld.com> Content-Type: text/plain Message-Id: <1092867689.29139.1414.camel@pelican.wigram> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.2.2 (1.2.2-4) Date: 19 Aug 2004 08:21:29 +1000 Content-Transfer-Encoding: 7bit X-Miltered: at nez-perce with ID 4123D67C.001 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Loop: caml-list@inria.fr X-Spam: no; 0.00; caml-list:01 overriding:01 sourceforge:01 2004:99 subtyping:01 subclassing:01 subclassing:01 subtyping:01 semantically:01 incompatible:01 semantically:01 9660:01 glebe:01 chris:01 ocaml:01 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk 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