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=none autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by yquem.inria.fr (Postfix) with ESMTP id 5E535BC68 for ; Mon, 18 Sep 2006 22:58:46 +0200 (CEST) Received: from out1.smtp.messagingengine.com (out1.smtp.messagingengine.com [66.111.4.25]) by concorde.inria.fr (8.13.6/8.13.6) with ESMTP id k8IKwfwH006710 for ; Mon, 18 Sep 2006 22:58:46 +0200 Received: from frontend3.internal (frontend3.internal [10.202.2.152]) by frontend1.messagingengine.com (Postfix) with ESMTP id AA69ADA7C58; Mon, 18 Sep 2006 16:58:33 -0400 (EDT) Received: from heartbeat1.internal ([10.202.2.160]) by frontend3.internal (MEProxy); Mon, 18 Sep 2006 16:58:35 -0400 X-Sasl-enc: 2JijwHzA56Zq4PvFB8lqEzip5+BhNlGJd7zcXJflFPwh 1158613114 Received: from [172.16.112.115] (burnham.ljcrf.edu [192.231.106.2]) by mail.messagingengine.com (Postfix) with ESMTP id 4F37664FC; Mon, 18 Sep 2006 16:58:34 -0400 (EDT) Date: Mon, 18 Sep 2006 13:58:10 -0700 (PDT) From: Martin Jambon X-X-Sender: martin@localhost To: Denis Bueno Cc: OCaml Mailing List Subject: Re: [Caml-list] Record field update using 'with' syntax In-Reply-To: <6dbd4d000609181322t787162anf370923383727626@mail.gmail.com> Message-ID: References: <6dbd4d000609181322t787162anf370923383727626@mail.gmail.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-j-chkmail-Score: MSGID : 450F0881.000 on concorde : j-chkmail score : X : 0/20 1 X-Miltered: at concorde with ID 450F0881.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; syntax:01 foo:01 foo:01 1977:98 2006,:98 unbound:01 wrote:01 arbitrary:01 caml-list:01 expression:01 int:01 int:01 jambon:01 jambon:01 defined:02 On Mon, 18 Sep 2006, Denis Bueno wrote: > Suppose a module M1 with the record > > type foo = {x : int; y : int; z : int};; > > and a member of its type. In another module, a qualified field > matching like the following works: > > match instance with > {M1.x = 5; y = 5; z = 100} -> (* something *) > > Why doesn't the following work in a function? > > {M1.instance with x = 20} ^^^^^^^^^^^ this is an arbitrary expression, it doesn't have to come from the module where the record type is defined, so you need to specify it too. > Example: > | # {M1.foo with x = 5};; > | Characters 0-19: > | {M1.foo with x = 5};; > | ^^^^^^^^^^^^^^^^^^^ > | Unbound record field label x That works: # {M1.foo with M1.x = 0; y = 0};; - : M1.foo = {M1.x = 0; M1.y = 0; M1.z = 10} Martin -- Martin Jambon, PhD http://martin.jambon.free.fr