From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from weis@localhost) by pauillac.inria.fr (8.6.10/8.6.6) id KAA16327 for caml-redistribution; Wed, 15 May 1996 10:32:26 +0200 Received: from gr6.u-strasbg.fr (gr6.u-strasbg.fr [130.79.6.86]) by pauillac.inria.fr (8.6.10/8.6.6) with SMTP id WAA08185 for ; Tue, 14 May 1996 22:00:11 +0200 Received: by gr6.u-strasbg.fr (4.1/SMI-3.2-jjp/4/6/92) id AA03001; Tue, 14 May 96 22:04:56 +0200 Date: Tue, 14 May 96 22:04:56 +0200 From: boos@gr6.u-strasbg.fr (Christian Boos) Message-Id: <9605142004.AA03001@gr6.u-strasbg.fr> To: pbrisset@eis.enac.dgac.fr Cc: caml-list@pauillac.inria.fr Subject: Re: type and class definition : recursion In-Reply-To: <199605141211.OAA06278@concorde.inria.fr> References: <199605141211.OAA06278@concorde.inria.fr> Sender: weis pbrisset@eis.enac.dgac.fr writes: > I would like to define a class and a type with a mutual recursion between > them. Something like > > type t = A > | B of c > and class c (x:t) = > val mutable value = x > end > > Is it possible with O'caml ? > > -------------- Yes : #type 'a t = A | B of 'a;; type 'a t = A | B of 'a #class c (x : 'a t) : 'a = val mutable value = x end;; class c ('a t) : 'a = val mutable value : 'a t end #let foo = new c A;; val foo : c = #let bar = new c (B foo);; val bar : c = # -- Christian