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=AWL autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail1-relais-roc.national.inria.fr (mail1-relais-roc.national.inria.fr [192.134.164.82]) by yquem.inria.fr (Postfix) with ESMTP id 516D7BBAF for ; Sat, 12 Jul 2008 16:26:48 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: ApoEAJtbeEjAXQIm/2dsb2JhbACpAw X-IronPort-AV: E=Sophos;i="4.30,349,1212357600"; d="scan'208";a="15035927" Received: from discorde.inria.fr ([192.93.2.38]) by mail1-smtp-roc.national.inria.fr with ESMTP; 12 Jul 2008 16:26:48 +0200 Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by discorde.inria.fr (8.13.6/8.13.6) with ESMTP id m6CEQYwj025648 (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=OK) for ; Sat, 12 Jul 2008 16:26:47 +0200 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: ApoEAJtbeEhQRFuw/2dsb2JhbACpAw X-IronPort-AV: E=Sophos;i="4.30,349,1212357600"; d="scan'208";a="13059421" Received: from furbychan.cocan.org ([80.68.91.176]) by mail2-smtp-roc.national.inria.fr with ESMTP/TLS/AES256-SHA; 12 Jul 2008 16:26:47 +0200 Received: from rich by furbychan.cocan.org with local (Exim 4.63) (envelope-from ) id 1KHg3j-0002cC-6q for caml-list@inria.fr; Sat, 12 Jul 2008 15:26:47 +0100 Date: Sat, 12 Jul 2008 15:26:47 +0100 To: caml-list@inria.fr Subject: Re: [Caml-list] Why can't immediate objects be extended? Message-ID: <20080712142647.GA9917@annexia.org> References: <20080712141200.GA8634@annexia.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20080712141200.GA8634@annexia.org> User-Agent: Mutt/1.5.13 (2006-08-11) From: Richard Jones X-Miltered: at discorde with ID 4878BF1A.000 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; 0100,:01 node:01 indirection:01 val:01 val:01 wrote:01 extensible:01 caml-list:01 inherit:01 inherit:01 tree:02 tree:02 string:02 string:02 objects:02 On Sat, Jul 12, 2008 at 03:12:00PM +0100, Richard Jones wrote: > let obj = object > inherit (typeof parent_obj) > method str = string_of_tree t > end in > Node (annotate left, obj, annotate right) Further exploration reveals I can write this, which is _almost_ what I want: let obj = object inherit object method parent = parent_obj end method str = string_of_tree t end in ... except the indirection through a parent method is not helpful for what I'm trying to achieve (an extensible static type that doesn't depend on the order in which the type is extended). The types produced by this are: val annotate : 'a tree -> < parent : 'a; str : string > tree = val tree : < parent : < >; str : string > tree = (* ... *) Rich. -- Richard Jones Red Hat