From: "Daniel Bünzli" <daniel.buenzli@erratique.ch>
To: OCaml Mailing List <caml-list@inria.fr>
Subject: Re: [Caml-list] let rec and environment sharing
Date: Thu, 30 Oct 2008 20:58:29 +0100 [thread overview]
Message-ID: <488D129D-0273-4DD0-AA2D-D39FC02594E6@erratique.ch> (raw)
In-Reply-To: <4d1b2df20810301240o77e110cft6070c5cd0ad863b6@mail.gmail.com>
Le 30 oct. 08 à 20:40, Philippe Wang a écrit :
> If you mean
[...]
No I'm talking about the internal representation. For example if you
implement objects with records :
> type o = { mutable m1 : unit -> bool; mutable m2 : unit -> int }
>
> let f bla =
> let rec m1 () = bla = 0
> and m2 () = bla + 1 in
> { m1 = m1; m2 = m2 }
Then I hope that the closure's environment of m1 and m2 is shared,
that they do not each store their own mapping from bla to value.
Another question I have is below, does bla leak after a call to m1 ?
> let g bla blu =
> let rec o = { m1 = m1; m2 = m2 }
> and m1 () =
> let rec m1' () = blu = 0 (* new method definitions
> refers only blu *)
> and m2' () = blu + 1 in
> o.m1 <- m1'; o.m2 <- m2';
> bla = 0
> and m2 () = bla + 1 in
> o
Best,
Daniel
next prev parent reply other threads:[~2008-10-30 19:59 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-10-30 19:04 Daniel Bünzli
[not found] ` <4d1b2df20810301240o77e110cft6070c5cd0ad863b6@mail.gmail.com>
2008-10-30 19:58 ` Daniel Bünzli [this message]
[not found] ` <4d1b2df20810310346j7824c379udceff0517c6eac94@mail.gmail.com>
[not found] ` <265BA436-5079-47E2-862E-9A1CD15ECDCB@erratique.ch>
[not found] ` <4d1b2df20810310843k79ef135fn5deaa9632272dd97@mail.gmail.com>
2008-10-31 16:10 ` [Caml-list] " Daniel Bünzli
2008-10-31 21:17 ` Zheng Li
2008-11-01 10:40 ` Daniel Bünzli
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=488D129D-0273-4DD0-AA2D-D39FC02594E6@erratique.ch \
--to=daniel.buenzli@erratique.ch \
--cc=caml-list@inria.fr \
/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).