caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Fabrice Le Fessant <Fabrice.Le_fessant@inria.fr>
To: caml-list@inria.fr
Subject: Re: [Caml-list] variable sharing
Date: Mon, 07 Mar 2011 11:24:16 +0100	[thread overview]
Message-ID: <4D74B250.7040607@inria.fr> (raw)
In-Reply-To: <1856328280.452099.1299464703924.JavaMail.root@zmbs4.inria.fr>

[-- Attachment #1: Type: text/plain, Size: 1977 bytes --]

let a = ...
let b = Some a
let c = b (* b and c share the same value *)
let d = Some a (* d = b,  but d != b, i.e. b and d don't share the same
value in memory *)

If you want b and d to share the same value, you have to use some kind
of h-consing, but the runtime won't do it for you by default.

--Fabrice
INRIA -- OCamlPro

On 03/07/2011 03:25 AM, Kihong Heo wrote:
> Sorry. It's my mistake. 
> not variable sharing, but "value sharing" which means alias.
> 
> For example, there is a big set and I want to make many subset of it.
> In my thought, if the aliases are made efficiently, the memory explosion does not make sense.
> I don't know exactly what's the problem (my programming style, data type, or it is a natural result, etc..).
> So I want to know the principle.
> 
> Thank you.
> Kihong
> 
> 2011. 3. 7., 오전 11:07, Yitzhak Mandelbaum 작성:
> 
>> Kihong,
>>
>> Could you elaborate on what you mean by "variable sharing" and what specifically is not happening as expected? Perhaps you could provide a small example that demonstrates the problem you're seeing?
>>
>> Cheers,
>> Yitzhak
>>
>>
>> On Mar 6, 2011, at 8:49 PM, Kihong Heo wrote:
>>
>>> Dear caml-list.
>>>
>>> I want to know how ocaml compiler make variable sharing.
>>> I believe the compiler do good job, but sometime memory consumption
>>> of my program does not make sense. 
>>> So I am curious about what the compiler did or how to make program memory efficiently.
>>>
>>> If you know some good notes or web pages for that issue, please let me know.
>>>
>>> Thank you.
>>>
>>> - Kihong Heo
>>>
>>> -- 
>>> Caml-list mailing list.  Subscription management and archives:
>>> https://sympa-roc.inria.fr/wws/info/caml-list
>>> Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
>>> Bug reports: http://caml.inria.fr/bin/caml-bugs
>>>
>>
>> -----------------------------
>> Yitzhak Mandelbaum
>>
>>
>>
> 
> --
> 허 기 홍 드림
> khheo@ropas.snu.ac.kr
> 서울대학교 프로그래밍 연구실
> 
> 
> 

[-- Attachment #2: fabrice_le_fessant.vcf --]
[-- Type: text/x-vcard, Size: 397 bytes --]

begin:vcard
fn:Fabrice LE FESSANT
n:LE FESSANT;Fabrice
org:INRIA Saclay -- Ile-de-France;Projet OCamlPro
adr;quoted-printable:;;Parc Orsay Universit=C3=A9 ;Orsay CEDEX;;91893;France
email;internet:fabrice.le_fessant@inria.fr
title;quoted-printable:Charg=C3=A9 de Recherche
tel;work:+33 1 74 85 42 14
tel;fax:+33 1 74 85 42 49 
url:http://fabrice.lefessant.net/
version:2.1
end:vcard


      parent reply	other threads:[~2011-03-07 10:24 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-03-07  1:49 Kihong Heo
2011-03-07  2:07 ` Yitzhak Mandelbaum
2011-03-07  2:24   ` Kihong Heo
2011-03-07 10:19     ` Daniel Bünzli
2011-03-07 10:39     ` Julien Signoles
     [not found]   ` <1856328280.452099.1299464703924.JavaMail.root@zmbs4.inria.fr>
2011-03-07 10:24     ` Fabrice Le Fessant [this message]

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=4D74B250.7040607@inria.fr \
    --to=fabrice.le_fessant@inria.fr \
    --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).