caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Martin Jambon <martin1977@laposte.net>
To: Denis Bueno <dbueno@gmail.com>
Cc: OCaml Mailing List <caml-list@inria.fr>
Subject: Re: [Caml-list] Record field update using 'with' syntax
Date: Mon, 18 Sep 2006 13:58:10 -0700 (PDT)	[thread overview]
Message-ID: <Pine.LNX.4.58.0609181352310.23069@localhost> (raw)
In-Reply-To: <6dbd4d000609181322t787162anf370923383727626@mail.gmail.com>

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


  reply	other threads:[~2006-09-18 20:58 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-09-18 20:22 Denis Bueno
2006-09-18 20:58 ` Martin Jambon [this message]
2006-09-18 21:00   ` [Caml-list] " Denis Bueno
2006-09-18 21:16     ` Yoann Padioleau

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Pine.LNX.4.58.0609181352310.23069@localhost \
    --to=martin1977@laposte.net \
    --cc=caml-list@inria.fr \
    --cc=dbueno@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).