[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: | 2006-09-18 (20:58) |
From: | Martin Jambon <martin1977@l...> |
Subject: | Re: [Caml-list] Record field update using 'with' syntax |
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