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.4 required=5.0 tests=AWL,DNS_FROM_RFC_ABUSE, 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 concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by yquem.inria.fr (Postfix) with ESMTP id C1B55BC69 for ; Mon, 18 Sep 2006 22:22:49 +0200 (CEST) Received: from nz-out-0102.google.com (nz-out-0102.google.com [64.233.162.197]) by concorde.inria.fr (8.13.6/8.13.6) with ESMTP id k8IKMmkn000568 for ; Mon, 18 Sep 2006 22:22:49 +0200 Received: by nz-out-0102.google.com with SMTP id m22so1388031nzf for ; Mon, 18 Sep 2006 13:22:48 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:to:subject:mime-version:content-type:content-transfer-encoding:content-disposition; b=eHFfP5PbEemLEVQ4a2pVrnR8XcmkviBh4m8n3hQDgEkJF41WZC0f4eNtw5ttLOtQOnVe6XyGwpuJ3RC1xc6pb4/HpOcaDbRjx6G/MnT5lh4iOVO60DALOyiSPvqbhdUai1jG849GlzWDhAwefNj872/ITj19K8Hg/ZTe6ex8b1U= Received: by 10.64.28.18 with SMTP id b18mr16860514qbb; Mon, 18 Sep 2006 13:22:48 -0700 (PDT) Received: by 10.65.132.5 with HTTP; Mon, 18 Sep 2006 13:22:48 -0700 (PDT) Message-ID: <6dbd4d000609181322t787162anf370923383727626@mail.gmail.com> Date: Mon, 18 Sep 2006 16:22:48 -0400 From: "Denis Bueno" To: "OCaml Mailing List" Subject: Record field update using 'with' syntax MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline X-j-chkmail-Score: MSGID : 450F0018.000 on concorde : j-chkmail score : X : 0/20 1 X-Miltered: at concorde with ID 450F0018.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; syntax:01 foo:01 ocaml:01 struct:01 foo:01 sig:01 val:01 unbound:01 exception:01 matched:01 int:01 int:01 caml:02 objective:02 match:02 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} It would seem easy to determine that x must name a field of a record inside M1. Thanks for your help. (Example in OCaml 3.09.2 below.) -Denis Example: ,---- | Objective Caml version 3.09.2 | | # module M1 = struct | type foo = {x : int; y : int; z : int};; | let foo = {x = 10; y = 10; z = 10};; | end;; | module M1 : sig type foo = { x : int; y : int; z : int; } val foo : foo end | # match M1.foo with | {M1.x = 5; y = 5} -> ();; | Characters 0-43: | Warning P: this pattern-matching is not exhaustive. | Here is an example of a value that is not matched: | {x=0} | match M1.foo with | {M1.x = 5; y = 5} -> ();; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | Exception: Match_failure ("", 1, 0). | # {M1.foo with x = 5};; | Characters 0-19: | {M1.foo with x = 5};; | ^^^^^^^^^^^^^^^^^^^ | Unbound record field label x | # `----