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 72923BC0A for ; Mon, 4 Jun 2007 22:14:01 +0200 (CEST) Received: from wa-out-1112.google.com (wa-out-1112.google.com [209.85.146.178]) by discorde.inria.fr (8.13.6/8.13.6) with ESMTP id l54KE0HB024767 for ; Mon, 4 Jun 2007 22:14:00 +0200 Received: by wa-out-1112.google.com with SMTP id j37so2151524waf for ; Mon, 04 Jun 2007 13:13:59 -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=oKy0lzX1ullYYn7yAS2il6FHXDTAKp/+H7uLipZrxeoPfk30meXD3YvnmtPzxEgbx3W6UjA+8vhBZw2OdbHcAb4ctbU2kmitcYVNvim/JspY3jymmYHg2oKFVhTBdTbMVWuD2dLPRQmyT7fVextZmgDYAnTuoXem5OagH6AfXXY= 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=fjR7oU+aw0EULEro1OZkMWNhel72dFHvuWghUx/jMe4XANBoggS9gCvN7sVD+hvQ8nBs556o112MRXzJAAHIsiCSbfEXb4ITsR+cpszdA0CLkxHNSNuyw2Qel4q+O7lqkBwI+3I9GDK18Ct0cfQUr0eoH7N/aJf+mo1UzxZBK/E= Received: by 10.115.22.1 with SMTP id z1mr2853384wai.1180988039145; Mon, 04 Jun 2007 13:13:59 -0700 (PDT) Received: by 10.114.181.8 with HTTP; Mon, 4 Jun 2007 13:13:59 -0700 (PDT) Message-ID: Date: Mon, 4 Jun 2007 22:13:59 +0200 From: "Nicolas Pouillard" To: "Raj B" Subject: Re: [Caml-list] OCaml object types vs record types Cc: caml-list@yquem.inria.fr In-Reply-To: <0EE1C559-A93C-4E66-AC70-8ADD1C21DDF8@rice.edu> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <0EE1C559-A93C-4E66-AC70-8ADD1C21DDF8@rice.edu> X-j-chkmail-Score: MSGID : 46647288.000 on discorde : j-chkmail score : X : 0/20 1 0.000 -> 1 X-Miltered: at discorde with ID 46647288.000 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; ocaml:01 subtyping:01 mutable:01 ocaml:01 foo:01 mutable:01 wrote:01 caml-list:01 coercion:01 int:01 int:01 objects:02 string:02 string:02 garrigue:03 On 6/4/07, Raj B wrote: > Hi there > > I'm writing an application where I'd modeling objects as record > types. However, I'd like to have a subtyping relation between them > along with (occasional) coercion. For example, > > type obj = {name : string} > type specialobj = {name: string; mutable value: int;...} > and so on... > The pa_oo extension from Jacques Garrigue does exactly this kind of things: http://www.math.nagoya-u.ac.jp/~garrigue/code/ocaml.html (works also in 3.10 but not released yet, contact me if you want it) Example: type obj = type specialobj = unit...> let o = {| name = "foo"; mutable value = 42 |} in o#name, o#value <- 43, o#value Regards, -- Nicolas Pouillard