From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail4-relais-sop.national.inria.fr (mail4-relais-sop.national.inria.fr [192.134.164.105]) by yquem.inria.fr (Postfix) with ESMTP id 72270BB84 for ; Fri, 26 Sep 2008 01:48:20 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: ArcAAJa/20hCbwQZlGdsb2JhbACTHwEBAQEJCQwHEQSoHoFl X-IronPort-AV: E=Sophos;i="4.33,309,1220220000"; d="scan'208";a="29596911" Received: from out1.smtp.messagingengine.com ([66.111.4.25]) by mail4-smtp-sop.national.inria.fr with ESMTP; 26 Sep 2008 01:48:19 +0200 Received: from compute1.internal (compute1.internal [10.202.2.41]) by out1.messagingengine.com (Postfix) with ESMTP id E72E3166EBD; Thu, 25 Sep 2008 19:48:17 -0400 (EDT) Received: from heartbeat2.messagingengine.com ([10.202.2.161]) by compute1.internal (MEProxy); Thu, 25 Sep 2008 19:48:17 -0400 X-Sasl-enc: /W5oWdihbG3N6prg7Z7jLowu/KToIfM4PjXB7SkiIxT2 1222386497 Received: from [192.168.1.10] (ALyon-157-1-77-101.w90-37.abo.wanadoo.fr [90.37.68.101]) by mail.messagingengine.com (Postfix) with ESMTPSA id 131FF30A85; Thu, 25 Sep 2008 19:48:16 -0400 (EDT) Date: Fri, 26 Sep 2008 01:41:29 +0200 (CEST) From: Martin Jambon X-X-Sender: martin@martin.ec.wink.com To: =?iso-8859-1?Q?S=E9bastien?= Hinderer Cc: caml-list@yquem.inria.fr Subject: Re: [Caml-list] mutually dependent class and type In-Reply-To: <20080925222439.GA7968@galois> Message-ID: References: <20080925222439.GA7968@galois> MIME-Version: 1.0 Content-Type: MULTIPART/MIXED; BOUNDARY="8323328-1802929845-1222386083=:10536" Content-ID: X-Spam: no; 0.00; ens-lyon:01 unreadable:01 mime-aware:01 recursive:01 ocaml:01 beginner's:01 ocaml:01 bug:01 beginners:01 wrote:01 readable:01 caml-list:01 caml-list:01 bin:01 jambon:01 This message is in MIME format. The first part should be readable text, while the remaining parts are likely unreadable without MIME-aware tools. --8323328-1802929845-1222386083=:10536 Content-Type: TEXT/PLAIN; CHARSET=iso-8859-1; FORMAT=flowed Content-Transfer-Encoding: 8BIT Content-ID: On Fri, 26 Sep 2008, Sébastien Hinderer wrote: > Dear list, > > Is there a (clean) way to define simultaneously a class and a type that > are mutually recursive ? I don't think so, but you don't have to. > Something like this : > class element (c : content) = > object > ... > end and type content = > | Data of string > | Elements of element list;; > > This is of course not a valid OCaml definition, but is there a way to > express it ? With each class comes a type of the same name. Such type can also be defined independently from the notion of class. It is syntactically like a record with angle brackets: type element = < content : content > and content = Data of string | Elements of element list;; class element_class (c : content) = object method content = c end # new element_class (Elements [ new element_class (Data "abc") ]);; - : element_class = Martin > Many thanks in advance for your help, > Sébastien. > > _______________________________________________ > Caml-list mailing list. Subscription management: > http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list > Archives: http://caml.inria.fr > Beginner's list: http://groups.yahoo.com/group/ocaml_beginners > Bug reports: http://caml.inria.fr/bin/caml-bugs > -- http://mjambon.com/ --8323328-1802929845-1222386083=:10536--