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 mail4-relais-sop.national.inria.fr (mail4-relais-sop.national.inria.fr [192.134.164.105]) by yquem.inria.fr (Postfix) with ESMTP id 43B9DBBC1 for ; Mon, 3 Mar 2008 17:54:59 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AgAAAG+8y0fUnw6FhWdsb2JhbACCNI4+AQEBCAQGBwgTB5t2 X-IronPort-AV: E=Sophos;i="4.25,438,1199660400"; d="scan'208";a="23306567" Received: from pih-relay06.plus.net ([212.159.14.133]) by mail4-smtp-sop.national.inria.fr with ESMTP; 03 Mar 2008 17:54:59 +0100 Received: from [80.229.56.224] (helo=beast.local) by pih-relay06.plus.net with esmtp (Exim) id 1JWDwH-0002H2-5j for caml-list@yquem.inria.fr; Mon, 03 Mar 2008 16:54:57 +0000 From: Jon Harrop Organization: Flying Frog Consultancy Ltd. To: caml-list@yquem.inria.fr Subject: Re: [Caml-list] different records, same field name? Date: Mon, 3 Mar 2008 16:53:50 +0000 User-Agent: KMail/1.9.7 References: In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200803031653.50394.jon@ffconsultancy.com> X-Plusnet-Relay: e4ea1ea1b5a3c6ad7b6e18650e492a1a X-Spam: no; 0.00; ocaml:01 toplevel:01 ocaml:01 toplevel:01 struct:01 struct:01 frog:98 wrote:01 caml-list:01 define:02 define:02 modules:02 module:03 module:03 float:03 On Monday 03 March 2008 16:51:57 mfmorss@aep.com wrote: > I have not used OCaml, just done some reading about it and toyed with the > toplevel to see if it might be a useful tool here. I have "Practical > OCaml," which unfortunately is a rather wretched reference. > > In any case, is it possible to define and use different types of records, > which nevertheless share some field names? I have had difficulty doing > this in the toplevel. Field names will shadow others so you define the record types in separate modules: module Vec2 = struct type t = {x: float; y: float} end module Vec3 = struct type t = {x: float; y: float; z: float} end { Vec2.x = 2.; y = 3. } -- Dr Jon D Harrop, Flying Frog Consultancy Ltd. http://www.ffconsultancy.com/products/?e