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 RAA29102; Tue, 3 Aug 2004 17:50:55 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f 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 RAA29578 for ; Tue, 3 Aug 2004 17:50:53 +0200 (MET DST) Received: from annexia.force9.co.uk (annexia.force9.co.uk [212.56.101.183]) by concorde.inria.fr (8.12.10/8.12.10) with ESMTP id i73FoqSH015640 for ; Tue, 3 Aug 2004 17:50:53 +0200 Received: from rich by annexia.force9.co.uk with local (Exim 3.36 #1 (Debian)) id 1Bs1YZ-0006hI-00; Tue, 03 Aug 2004 16:50:27 +0100 Date: Tue, 3 Aug 2004 16:50:27 +0100 To: John Prevost Cc: Ocaml Mailing List Subject: Re: [Caml-list] Functors and classes Message-ID: <20040803155026.GB25124@annexia.org> References: <20040803120244.GA22304@annexia.org> <20040803121049.GA22418@annexia.org> <20040803131716.GA22773@annexia.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.5.1+cvs20040105i From: Richard Jones X-Miltered: at concorde with ID 410FB45D.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Loop: caml-list@inria.fr X-Spam: no; 0.00; caml-list:01 functors:01 2004:99 0400,:01 prevost:01 struct:01 conn:01 conn:01 val:01 val:01 struct:01 footprints:01 giants:99 ltd:98 sig:01 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk On Tue, Aug 03, 2004 at 11:06:33AM -0400, John Prevost wrote: I've found a problem with this approach. If I replace the connect function here: > module ThingPool (Thing : ThingIntf) : > (ThingPoolT with type connection = Thing.connection) = > struct > type connection = Thing.connection > let connect () = Thing.connect () > end with: let connect () = let conn = Thing.connect () in ignore (conn#a); conn then I get the following error: File "test.ml", line 30, characters 14-18: This expression has type Thing.connection It has no method a So I extended the type of connection as follows to make it work: module type ThingIntf = sig type connection = val connect : unit -> connection end That's all well and good. BUT I need to define something more like this: module type ThingIntf = sig type connection = val connect : unit -> connection end which gives me: File "test.ml", line 14, characters 8-35: A type variable is unbound in this type declaration (I'm only uses a small subset of the much larger interface in my pooling code). Full code which fails is attached. Thanks, Rich. ---------------------------------------------------------------------- module TestThing = struct class connection = object method a = 1 method b = 1 method c = 1 end let connect () = new connection end module type ThingIntf = sig type connection = val connect : unit -> connection end module type ThingPoolT = sig type connection val connect : unit -> connection end module ThingPool (Thing : ThingIntf) : (ThingPoolT with type connection = Thing.connection) = struct type connection = Thing.connection let connect () = let conn = Thing.connect () in ignore (conn#a); conn end module X = ThingPool(TestThing) let x = X.connect () let a = x #a let b = x #b let c = x #c ---------------------------------------------------------------------- -- Richard Jones. http://www.annexia.org/ http://www.j-london.com/ Merjis Ltd. http://www.merjis.com/ - improving website return on investment If I have not seen as far as others, it is because I have been standing in the footprints of giants. -- from Usenet ------------------- 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