From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by walapai.inria.fr (8.13.6/8.13.6) with ESMTP id p2SIYHMg023649 for ; Mon, 28 Mar 2011 20:34:17 +0200 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AvkDAH/TkE3Cpx5ei2dsb2JhbACYFI0rFAEBAQoLCxsliGu7JYVpBJBL X-IronPort-AV: E=Sophos;i="4.63,256,1299452400"; d="scan'208";a="95245363" Received: from sucre.univ-orleans.fr ([194.167.30.94]) by mail2-smtp-roc.national.inria.fr with ESMTP; 28 Mar 2011 20:34:12 +0200 Received: from localhost (localhost [127.0.0.1]) by sucre.univ-orleans.fr (Postfix) with ESMTP id 6E8D2943B7; Mon, 28 Mar 2011 20:34:12 +0200 (CEST) Received: from sucre.univ-orleans.fr ([127.0.0.1]) by localhost (sucre.univ-orleans.fr [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id jKH4TqzGDF4Q; Mon, 28 Mar 2011 20:34:12 +0200 (CEST) Received: from smtps.univ-orleans.fr (smtps.univ-orleans.fr [194.167.30.152]) by sucre.univ-orleans.fr (Postfix) with ESMTP id 517B194383; Mon, 28 Mar 2011 20:34:12 +0200 (CEST) Received: from [192.168.0.11] (dau94-10-88-189-211-192.fbx.proxad.net [88.189.211.192]) by smtps.univ-orleans.fr (Postfix) with ESMTP id 82A4836E60; Mon, 28 Mar 2011 20:34:15 +0200 (CEST) Mime-Version: 1.0 (Apple Message framework v1084) Content-Type: text/plain; charset=us-ascii From: David Rajchenbach-Teller In-Reply-To: <74205EDF-69A3-479A-9214-52D2AB849558@gmail.com> Date: Mon, 28 Mar 2011 20:34:10 +0200 Cc: caml-list Message-Id: References: <74205EDF-69A3-479A-9214-52D2AB849558@gmail.com> To: Joel Reymont X-Mailer: Apple Mail (2.1084) Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from quoted-printable to 8bit by walapai.inria.fr id p2SIYHMg023649 Subject: Re: [Caml-list] function that works on different record types, assuming they have a given field Nope, in OCaml, a field name unambiguously identifies the type of the record. On the other hand, you can obtain the same behavior by using objects instead of records: # let f x = x#foo;; val f : < foo : 'a; .. > -> 'a = Hope this helps, David On Mar 28, 2011, at 8:16 PM, Joel Reymont wrote: > Is it possible to write a function that works on different record types that have, say, a field x of type int? > > The records would be in different modules but the field name and type will always be the same. > > Thanks, Joel > > -------------------------------------------------------------------------- > - for hire: mac osx device driver ninja, kernel extensions and usb drivers > ---------------------+------------+--------------------------------------- > http://wagerlabs.com | @wagerlabs | http://www.linkedin.com/in/joelreymont > ---------------------+------------+--------------------------------------- > > > > > > -- > Caml-list mailing list. Subscription management and archives: > https://sympa-roc.inria.fr/wws/info/caml-list > Beginner's list: http://groups.yahoo.com/group/ocaml_beginners > Bug reports: http://caml.inria.fr/bin/caml-bugs >