From mboxrd@z Thu Jan 1 00:00:00 1970 X-Sympa-To: caml-list@inria.fr Received: from mail1-relais-roc.national.inria.fr (mail1-relais-roc.national.inria.fr [192.134.164.82]) by walapai.inria.fr (8.13.6/8.13.6) with ESMTP id p42CWkDV015030 for ; Mon, 2 May 2011 14:32:46 +0200 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Am0KACqjvk1ii1taaWdsb2JhbACYU41dDQkLBxMoow2ceYYABI55hBkmiWU X-IronPort-AV: E=Sophos;i="4.64,302,1301868000"; d="scan'208";a="107233124" Received: from nm20.bullet.mail.sp2.yahoo.com ([98.139.91.90]) by mail1-smtp-roc.national.inria.fr with SMTP; 02 May 2011 14:32:40 +0200 Received: from [98.139.91.67] by nm20.bullet.mail.sp2.yahoo.com with NNFMP; 02 May 2011 12:32:39 -0000 Received: from [98.136.185.47] by tm7.bullet.mail.sp2.yahoo.com with NNFMP; 02 May 2011 12:32:39 -0000 Received: from [127.0.0.1] by smtp108.mail.gq1.yahoo.com with NNFMP; 02 May 2011 12:32:39 -0000 X-Yahoo-Newman-Id: 265491.76952.bm@smtp108.mail.gq1.yahoo.com Received: from [192.168.1.186] (createsoftware@93.7.165.241 with plain) by smtp108.mail.gq1.yahoo.com with SMTP; 02 May 2011 05:32:38 -0700 PDT X-Yahoo-SMTP: nOQXzg.swBB4sp2etEdz2uv_gATJYHejNKHVByHxjw-- X-YMail-OSG: 01kyrmkVM1kdoTG68AxCGTXQNzqYIn5AbMPD9C6BXF.J1Pt RlzJwQxwujzJUf87ttHvZeV6GAW4rUfKpgu2z4UfhZ438GIC0qvkVjkRG3FC 8w0pQA3AOiGezYe62kdqisiaqd9TpP.oy_ztYfUUu3njIUxTRTRu1YXHVgh_ BLxqmTcBQSoTgnSVXU8Tvb5P180Fp.768YtK4DyFMChNYJ8quv.9X9MnCkDd vP_vSpXCmz_eTKA3V65MUzEs85bhWlfioIdtQ2lE2wjkTzmlUVfCQjY47T.D BhJ_GKIjAH6F2eONi.mxU89SmajoNs2gkRJVyozOMhGT0lnvSjkV316YnzLt VAtjm_kMbYEQ0pNav0FA_OBkpeGqL7Exl X-Yahoo-Newman-Property: ymail-3 Message-ID: <4DBEA464.7090102@users.sourceforge.net> Date: Mon, 02 May 2011 14:32:36 +0200 From: Create Software User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; fr; rv:1.9.2.17) Gecko/20110414 Lightning/1.0b2 Thunderbird/3.1.10 MIME-Version: 1.0 To: caml-list@inria.fr Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8bit X-Validation-by: createsoftware@users.sourceforge.net Subject: [Caml-list] Pattern-matching on Ocaml records Hi all, I'm building an old Caml Light program with OCaml, and I've come across a reluctant piece of code. Here's a a mwe: type t = {mutable label: int};; let reset {label = lbl} = lbl <- 0;; let test = {label = -1};; reset test;; test;; This compiles fine in Caml Light, yielding Type t defined. reset : t -> unit = test : t = {label = -1} - : unit = () - : t = {label = 0} On the other hand, Ocaml refuses this snippet, and prints the following message: Characters 26-34: let reset {label = lbl} = lbl <- 0;; ^^^^^^^^ Error: Unbound instance variable lbl Was this construct deprecated? If so, why? Thanks! Clément. PS: I also tried let reset' a = let lbl = a.label in lbl <- 0 ;; but "The identifier lbl is not mutable.", in both OCaml and Caml Light. Why so?