From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: weis Received: (from weis@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id SAA31213 for caml-redistribution; Fri, 24 Sep 1999 18:05:31 +0200 (MET DST) 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 OAA25350 for ; Fri, 24 Sep 1999 14:35:27 +0200 (MET DST) Received: from pauillac.inria.fr (pauillac.inria.fr [128.93.11.35]) by concorde.inria.fr (8.8.7/8.8.7) with ESMTP id OAA12101; Fri, 24 Sep 1999 14:35:25 +0200 (MET DST) Received: (from vouillon@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id OAA28416; Fri, 24 Sep 1999 14:35:24 +0200 (MET DST) Message-ID: <19990924143524.57189@pauillac.inria.fr> Date: Fri, 24 Sep 1999 14:35:24 +0200 From: Jerome Vouillon To: Peter Schrammel , Pierre Weis , caml-list@inria.fr Subject: Re: Tree of a certain class: References: <199909171244.OAA22193@pauillac.inria.fr> <37EB3338.4E226250@unibw-muenchen.de> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Mailer: Mutt 0.89.1 In-Reply-To: <37EB3338.4E226250@unibw-muenchen.de>; from Peter Schrammel on Fri, Sep 24, 1999 at 10:15:52AM +0200 Sender: weis On Fri, Sep 24, 1999 at 10:15:52AM +0200, Peter Schrammel wrote: > I wrote a Program: > type 'i tree = > Empty > | Item of 'i > | Section of 'i * 'i > > class ['i] ctree = > object (self : 'a) > val mutable content : 'i tree = Empty > > method get = content > > end > > class debug = > object > method debug = () > end > > class dtree = > object > inherit [#debug] ctree > end > > But the compiler gives me the error: > > Some type variables are unbound in this type: > class dtree : > object val mutable content : (#debug as 'a) tree method get : 'a > tree end > The method get has type #debug tree where .. is unbound > make: *** [test.cmo] Error 2 > > How can make trees of a certain (sub)class ? (I hope there's a simple > solution) Depending on your needs, you can either write class dtree = object inherit [debug] ctree end or class ['a] dtree = object constraint 'a = #debug inherit ['a] ctree end In the first case, the type of the contained object is fixed. In the second case it is only required to be an instance of type #debug = < debug : unit; .. > So, if you write a subclass debug2 of class debug, an object of type "debug2 dtree" will contain objects of type "debug2". Regards, -- Jérôme