From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from weis@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id OAA08189 for caml-redistribution; Fri, 22 Nov 1996 14:19:36 +0100 (MET) Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id SAA03049 for ; Thu, 21 Nov 1996 18:12:31 +0100 (MET) Received: from margaux.inria.fr (margaux.inria.fr [128.93.8.2]) by concorde.inria.fr (8.7.6/8.7.1) with ESMTP id SAA03202 for ; Thu, 21 Nov 1996 18:12:30 +0100 (MET) Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by margaux.inria.fr (8.7.6/8.7.3) with ESMTP id SAA28541 for ; Thu, 21 Nov 1996 18:12:30 +0100 (MET) Received: from arthur.u-strasbg.fr (boos@arthur.u-strasbg.fr [130.79.6.103]) by concorde.inria.fr (8.7.6/8.7.1) with ESMTP id SAA03198 for ; Thu, 21 Nov 1996 18:12:28 +0100 (MET) Received: (from boos@localhost) by arthur.u-strasbg.fr (8.7.5/8.7.3) id SAA08291; Thu, 21 Nov 1996 18:10:27 +0100 Date: Thu, 21 Nov 1996 18:10:27 +0100 Message-Id: <199611211710.SAA08291@arthur.u-strasbg.fr> From: Christian Boos To: Hendrik Tews CC: caml-list@margaux.inria.fr Subject: Questions about class types In-Reply-To: <199611211357.OAA10366@ithif18.inf.tu-dresden.de> References: <199611211357.OAA10366@ithif18.inf.tu-dresden.de> Sender: weis Hello, Hendrik Tews writes: > ... > Unfortunately B does not match A, because (as it is written in > the documentation under 4.9.2) one can add additional instance > variables, but no additional methods. What is the reason for > this? That's a good question. Maybe O'Caml will add private methods some day ? > The first idea is to implement f as an instance variable (of > functional type) as well, but this gets very ugly as soon as > there are some mutually recursive f's. But this helps in some cases ! > The next idea was to specify only a type and some > functionality, not a class ie: > This is a good idea. You're mistake was on using the ellipsis '..' which doesn't seem to be needed in your example. Here is an example how to write it: module type A' = sig val newb : unit -> < init : unit > end module B' : A' = struct class b () as self = val a = () method init = self#f method f = a end let newb () = (new b () :> < init : unit >) end This compiles fine ! -- Christian