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 OAA17388; Sat, 5 Jan 2002 14:16:53 +0100 (MET) 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 OAA17183 for ; Sat, 5 Jan 2002 14:16:53 +0100 (MET) Received: from nef.ens.fr (nef.ens.fr [129.199.96.32]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id g05DGqD23278 for ; Sat, 5 Jan 2002 14:16:52 +0100 (MET) Received: from clipper.ens.fr (clipper-gw.ens.fr [129.199.1.22]) by nef.ens.fr (8.10.1/1.01.28121999) with ESMTP id g05DGpZ01699 ; Sat, 5 Jan 2002 14:16:51 +0100 (CET) Received: from localhost (frisch@localhost) by clipper.ens.fr (8.9.2/jb-1.1) id OAA29357 ; Sat, 5 Jan 2002 14:16:51 +0100 (MET) Date: Sat, 5 Jan 2002 14:16:50 +0100 (MET) From: Alain Frisch To: cc: Subject: Re: [Caml-list] A class that contains instances of itself? In-Reply-To: <200201051245.g05Cjxp24150@war.OCF.Berkeley.EDU> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk On Sat, 5 Jan 2002 wrader@ocf.berkeley.edu wrote: > I want to have an class that can contain instances > of that same class. Assume something like this: > (ignore any easy syntax errors - I'm making > up this example right now) ... What about : class someClass = object(_ : 'self) val mutable anotherInstanceOfSomeClass : 'self option = None method talk () = print_string("Hello.\n") method setInstance x = anotherInstanceOfSomeClass <- Some x method useInstance () = match anotherInstanceOfSomeClass with | Some a -> a # talk () | None -> () end ? -- Alain ------------------- Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr