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 p12Jd6Je015921 for ; Wed, 2 Feb 2011 20:39:07 +0100 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AiEBAGZBSU1KfVIuimdsb2JhbACWSYFXjHUIFQEBAQoJDAcPBiCheIwdAQWNYQEEhVOUDTqDAA X-IronPort-AV: E=Sophos;i="4.60,415,1291590000"; d="scan'208";a="87320100" Received: from mail-ww0-f46.google.com ([74.125.82.46]) by mail4-smtp-sop.national.inria.fr with ESMTP/TLS/RC4-MD5; 02 Feb 2011 20:39:07 +0100 Received: by wwj40 with SMTP id 40so359140wwj.3 for ; Wed, 02 Feb 2011 11:39:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=gamma; h=domainkey-signature:from:to:cc:references:in-reply-to:subject:date :organization:message-id:mime-version:content-type :content-transfer-encoding:x-mailer:thread-index:content-language; bh=eDbJaSkgNn01Njsk/VSZsWiJjmjcasajxttfshFz0Vc=; b=F8XBkAoz5Wo8mzJRIGDxzq7o80opZ+Dtf7jDkUxxP7zSc9+oBGJN3/AbO3cymAd4Jo 4H7A00CzpDl3ONu570CePlGH8htXemqiqqDSdWdRJtFcXll4xXLLRFelMgI0f3t0xGld mg3vFOLKH1NbhaA125PfGOAEIUORUahPzj/Lw= DomainKey-Signature: a=rsa-sha1; c=nofws; d=googlemail.com; s=gamma; h=from:to:cc:references:in-reply-to:subject:date:organization :message-id:mime-version:content-type:content-transfer-encoding :x-mailer:thread-index:content-language; b=nbNsAUVK4lMKHINFmZNff+9AFOVhjUV/wjziU5tF1VbDZ7vElpzpkMtARFu5+XE5+5 ckpTZugVUL2QdH1P0XBXn9PhbXZT26HMry/UmOdi9G9SkjonCCLNhg6VvsQh0owo7CsL HFRB+2QBQCGAkdBmOn3DbbKoLqGKSj1DGigM0= Received: by 10.227.156.5 with SMTP id u5mr4471920wbw.28.1296675546176; Wed, 02 Feb 2011 11:39:06 -0800 (PST) Received: from WinEight (231.98.112.87.dyn.plus.net [87.112.98.231]) by mx.google.com with ESMTPS id f27sm6349662wbf.1.2011.02.02.11.39.02 (version=SSLv3 cipher=RC4-MD5); Wed, 02 Feb 2011 11:39:03 -0800 (PST) From: Jon Harrop To: "'Alain Frisch'" , "'Nicolas Ojeda Bar'" Cc: References: <476C4EB3-59D2-4756-927C-C1697E7AE4D8@math.harvard.edu> <4D46FB9E.5040805@lexifi.com> In-Reply-To: <4D46FB9E.5040805@lexifi.com> Date: Wed, 2 Feb 2011 19:38:48 -0000 Organization: Flying Frog Consultancy Message-ID: <015301cbc310$d1405b60$73c11220$@com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Mailer: Microsoft Office Outlook 12.0 Thread-Index: AcvBco05wZXQ1dmtTQCJ2LsDVlMDQgBnhY/w Content-Language: en-gb Subject: RE: [Caml-list] reference cells Don't you add the redundant 1.0 *. x at the end of numerical functions to trick ocamlopt into unboxing because the mutable variable used only internally in the function's body is heap allocated otherwise? Cheers, Jon. > -----Original Message----- > From: Alain Frisch [mailto:alain.frisch@lexifi.com] > Sent: 31 January 2011 18:13 > To: Nicolas Ojeda Bar > Cc: caml-list@yquem.inria.fr > Subject: Re: [Caml-list] reference cells > > On 01/31/2011 05:29 PM, Nicolas Ojeda Bar wrote: > > 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. > > Mutable variables which are used only internally in a function's body > are not heap allocated. > > If you write: > > let r = ref e0 in e1 > > and r only appears in e1 under the form: > > r := ... > !r > > and not under a local abstraction, then the reference is kept in a > local > variable. > > You can use the -dlambda switch to the compilers and toplevel to see > that. > > > -- Alain > > -- > 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