caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Guillaume Yziquel <guillaume.yziquel@citycable.ch>
To: Nicolas Ojeda Bar <nojb@math.harvard.edu>
Cc: caml-list@yquem.inria.fr
Subject: Re: [Caml-list] reference cells
Date: Mon, 31 Jan 2011 17:46:31 +0100	[thread overview]
Message-ID: <20110131164630.GN18069@localhost> (raw)
In-Reply-To: <476C4EB3-59D2-4756-927C-C1697E7AE4D8@math.harvard.edu>

Le Monday 31 Jan 2011 à 11:29:01 (-0500), Nicolas Ojeda Bar a écrit :
> Hello,

Hi.

> I am translating an imperative language into Ocaml. Right now I am
> translating mutable variables into ref cells. Will they be optimized
> when I compile the corresponding Ocaml program? Or will they be heap
> allocated? If this is the case, I will have to translate my language
> into some sort of SSA form before, and I would like to avoid that.
> 

Heap allocated. Indeed:

> yziquel@seldon:~$ ocaml
>         Objective Caml version 3.12.0
> 
> # let x = ref 10;;
> val x : int ref = {contents = 10}
> # Obj.tag (Obj.repr x);;
> - : int = 0
> # Obj.size (Obj.repr x);;
> - : int = 1
> # (Obj.magic (Obj.field (Obj.repr x) 0) : int);;
> - : int = 10
> # 

-- 
     Guillaume Yziquel


  parent reply	other threads:[~2011-01-31 16:48 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-01-31 16:29 Nicolas Ojeda Bar
2011-01-31 16:36 ` Michael Ekstrand
2011-01-31 16:46 ` Guillaume Yziquel [this message]
2011-02-04 11:49   ` David Baelde
2011-02-04 12:30     ` Guillaume Yziquel
2011-01-31 18:12 ` Alain Frisch
2011-02-02 19:38   ` Jon Harrop

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=20110131164630.GN18069@localhost \
    --to=guillaume.yziquel@citycable.ch \
    --cc=caml-list@yquem.inria.fr \
    --cc=nojb@math.harvard.edu \
    /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).