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=1.1 required=5.0 tests=AWL,SPF_NEUTRAL autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from discorde.inria.fr (discorde.inria.fr [192.93.2.38]) by yquem.inria.fr (Postfix) with ESMTP id EE765BC69 for ; Mon, 16 Jul 2007 04:27:55 +0200 (CEST) Received: from nz-out-0506.google.com (nz-out-0506.google.com [64.233.162.227]) by discorde.inria.fr (8.13.6/8.13.6) with ESMTP id l6G2Rtcg011146 for ; Mon, 16 Jul 2007 04:27:55 +0200 Received: by nz-out-0506.google.com with SMTP id x7so642015nzc for ; Sun, 15 Jul 2007 19:27:54 -0700 (PDT) DKIM-Signature: a=rsa-sha1; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=Fs0kLJvcLjBE5ckhyvUl0Ho5am5UhboYux8Jj3wErChLFGR0C8Smnt3oiASy4wPGIg9Kq3MlYaPhWD2tLtXpavFnK0bdyAMuSpmOkBUqTgAB9mjoVzrayadyZfj/t5KzaQse8opYuIjhRL5BIJwKYn4+WXaiAkUrL+ZMutK9grQ= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=Zw93FJpiVG9QgYBMJjku25F7mTp/MO6QKPjBW5ZzNAUn7WlFFDSh0mb+iNe/2pUJEcKd1Eoy5qYG7KVZww3lxyc1d38J2Hcq7i782i3Nv2gGRAo7COicmGqYnJ+cTwOuhn2MgJcK+1kNSAWvr5NhOBcffkIVGEw5ypeT0b3iL7U= Received: by 10.114.130.1 with SMTP id c1mr3723226wad.1184552873308; Sun, 15 Jul 2007 19:27:53 -0700 (PDT) Received: by 10.114.208.5 with HTTP; Sun, 15 Jul 2007 19:27:53 -0700 (PDT) Message-ID: <875c7e070707151927t529c3e2anb2dc9a5c5bf634fe@mail.gmail.com> Date: Sun, 15 Jul 2007 22:27:53 -0400 From: "Chris King" To: "Raj B" Subject: Re: [Caml-list] Recursive class+type definitions Cc: caml-list@yquem.inria.fr In-Reply-To: <11E0700C-4331-42AB-88F1-E6BD21D72F78@rice.edu> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <11E0700C-4331-42AB-88F1-E6BD21D72F78@rice.edu> X-j-chkmail-Score: MSGID : 469AD7AB.000 on discorde : j-chkmail score : X : 0/20 1 0.000 -> 1 X-Miltered: at discorde with ID 469AD7AB.000 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; recursive:01 getx:01 recursion:01 getx:01 recursive:01 verbose:01 wrote:01 signatures:01 caml-list:01 pair:01 modules:02 modules:02 float:03 float:03 cons:04 On 7/15/07, Raj B wrote: > class virtual mypoint = > object > method virtual getx : float > method virtual getlist : mypointlist > end > > type mypointlist = Empty | Cons of (mypoint * mypointlist) > > What is the best way to achieve this kind of mutual recursion? I'd write something like: type mypointlist = Empty | Cons of (< getx: float; getlist: mypointlist > * mypointlist) class virtual ... or: type mypointlist = Empty | Cons of (mypoint * mypointlist) and mypoint = < getx: float; getlist: mypointlist > in the case that having an inheritable virtual class isn't important to you. You can get the exact behavior you want using a pair of recursive modules (see the "Language Extensions" section of the manual), one for each of mypoint and mypointlist, but it's a lot more verbose (since recursive modules require you to explicity give their signatures). HTH, Chris