From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail4-relais-sop.national.inria.fr (mail4-relais-sop.national.inria.fr [192.134.164.105]) by walapai.inria.fr (8.13.6/8.13.6) with ESMTP id p0VGmKli022477 for ; Mon, 31 Jan 2011 17:48:20 +0100 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AvMIAFJ2Rk1V2gB4Zmdsb2JhbAClDg0LCAgSJL1BDYVBBJABiDE X-IronPort-AV: E=Sophos;i="4.60,404,1291590000"; d="scan'208";a="87173403" Received: from emailfrontal1.citycable.ch ([85.218.0.120]) by mail4-smtp-sop.national.inria.fr with SMTP; 31 Jan 2011 17:48:15 +0100 X-Alinto-smtpauth-localdomain: Yes Received: from seldon (unknown [85.218.92.99]) (Authenticated sender: guillaume.yziquel@citycable.ch) by emailfrontal1.citycable.ch (Postfix) with ESMTPA id 14DBF12C90C; Mon, 31 Jan 2011 17:48:09 +0100 (CET) Received: from yziquel by seldon with local (Exim 4.72) (envelope-from ) id 1Pjwtb-0000Vs-5v; Mon, 31 Jan 2011 17:46:31 +0100 Date: Mon, 31 Jan 2011 17:46:31 +0100 From: Guillaume Yziquel To: Nicolas Ojeda Bar Cc: caml-list@yquem.inria.fr Message-ID: <20110131164630.GN18069@localhost> References: <476C4EB3-59D2-4756-927C-C1697E7AE4D8@math.harvard.edu> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline In-Reply-To: <476C4EB3-59D2-4756-927C-C1697E7AE4D8@math.harvard.edu> User-Agent: Mutt/1.5.20 (2009-06-14) Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from quoted-printable to 8bit by walapai.inria.fr id p0VGmKli022477 Subject: Re: [Caml-list] reference cells 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