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,HTML_MESSAGE,SPF_SOFTFAIL autolearn=disabled version=3.1.3 Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by yquem.inria.fr (Postfix) with ESMTP id CCE80BC69 for ; Tue, 21 Aug 2007 15:18:18 +0200 (CEST) Received: from mail-red.research.att.com (mail-red.research.att.com [192.20.225.110]) by concorde.inria.fr (8.13.6/8.13.6) with ESMTP id l7LDIIok016568 for ; Tue, 21 Aug 2007 15:18:18 +0200 Received: from [192.168.0.100] (vpn-27.research.att.com [135.207.240.27]) by bigmail.research.att.com (8.13.7+Sun/8.11.6) with ESMTP id l7LDIFVs001339 for ; Tue, 21 Aug 2007 09:18:15 -0400 (EDT) Mime-Version: 1.0 (Apple Message framework v752.3) To: caml-list@yquem.inria.fr Message-Id: <67ECB685-E69A-43CA-867D-30B879DB0510@research.att.com> Content-Type: multipart/alternative; boundary=Apple-Mail-100--1058314500 From: Yitzhak Mandelbaum Subject: "opening" record types Date: Tue, 21 Aug 2007 09:18:02 -0400 X-Mailer: Apple Mail (2.752.3) X-j-chkmail-Score: MSGID : 46CAE61A.000 on concorde : j-chkmail score : X : 0/20 1 0.000 -> 1 X-Miltered: at concorde with ID 46CAE61A.000 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; yitzhak:01 mandelbaum:01 yitzhak:01 constructors:01 foo:01 struct:01 foo:01 cheers:01 mandelbaum:01 struct:01 cheers:01 averse:98 nuisance:98 averse:98 nuisance:98 --Apple-Mail-100--1058314500 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed Hi, I'm generally averse to opening modules, as I find it can make it hard to figure out where definitions are coming from. Instead, I prefer to bind only those pieces of the module that I need, and to do so explicitly. However, there is one instance in which I find myself with little choice: record types. In order to bind the field- constructors for a record, you need to copy the entire type from the module in which its declared. For example, module Foo = struct type t = {a: int; b:int} end without copying the type: let y = {Foo.a=3; Foo.b=4} with copying: type t = Foo.t = {a: int; b:int} let x = {a=3; b=4} While this is a nuisance to begin with, its even worse if the record type is subject to change -- each time it changes, you need to update every place where you copied the definition. Is there any way around this? That is, is there any way to use the field names of a record defined in another module without opening the whole module or copying the whole definition of the record. Cheers, Yitzhak -------------------------------------------------- Yitzhak Mandelbaum AT&T Labs - Research http://www.research.att.com/~yitzhak --Apple-Mail-100--1058314500 Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=ISO-8859-1 Hi,

I'm generally averse to = opening modules, as I find it can make it hard to figure out where = definitions are coming from. Instead, I prefer to bind only those pieces = of the module that I need, and to do so explicitly.=A0 However, there is = one instance in which I find myself with little choice: record types.=A0 = In order to bind the field-constructors for a record, you need to copy = the entire type from the module in which its declared. For = example,

module= Foo =3D=A0
struct
=A0 type t =3D {a: int; = b:int}
end

without copying the = type:

let y =3D= {Foo.a=3D3; Foo.b=3D4}

with = copying:=A0

type t =3D Foo.t =3D=A0=A0{a:= int; b:int}

let x =3D {a=3D3; = b=3D4}

While = this is a nuisance to begin with, its even worse if the record type is = subject to change -- each time it changes, you need to update every = place where you copied the definition.

Is there any way around = this?=A0 That is, is there any way to use the field names of a record = defined in another module without opening the whole module or copying = the whole definition of the record.

Cheers,
= --Apple-Mail-100--1058314500--