From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by yquem.inria.fr (Postfix) with ESMTP id B8A74BC57 for ; Wed, 1 Sep 2010 09:46:10 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Ai8BAA+ifUzBvsFKmWdsb2JhbACDGJAnjTYBAQEBAQgLCgcRIogkoyYBkjKBH4MkdgSKEQ X-IronPort-AV: E=Sophos;i="4.56,303,1280700000"; d="scan'208";a="56329153" Received: from dnsp.umh.ac.be (HELO hermes1.umh.ac.be) ([193.190.193.74]) by mail3-smtp-sop.national.inria.fr with ESMTP; 01 Sep 2010 09:46:10 +0200 Received: from poincare (poincare.swapping.umh.ac.be [10.102.100.95]) by hermes1.umh.ac.be (8.14.2/8.13.6) with ESMTP id o817daY6434206; Wed, 1 Sep 2010 09:39:36 +0200 Received: from localhost ([::1]) by poincare with esmtp (Exim 4.72) (envelope-from ) id 1Oqi1I-0001Fr-0T; Wed, 01 Sep 2010 09:46:08 +0200 Date: Wed, 01 Sep 2010 09:46:07 +0200 (CEST) Message-Id: <20100901.094607.1753910472605096940.Christophe.Troestler+ocaml@umons.ac.be> To: dmitry.bely@gmail.com Cc: caml-list@inria.fr Subject: Re: [Caml-list] Re: Question about float refs. From: Christophe TROESTLER In-Reply-To: References: <031b01cb4944$77110900$65331b00$@com> X-Face: #2fb%mPx>rRL@4ff~TVgZ"<[:,oL"`TUEGK/[8/qb58~C>jR(x4A+v/n)7BgpEtIph_neoLKJBq0JBY9:}8v|j Organization: University of Mons Return-Receipt-To: Christophe.Troestler@umons.ac.be Disposition-Notification-To: Christophe.Troestler@umons.ac.be X-Mailer: Mew version 6.3.50 on Emacs 23.2 / Mule 6.0 (HANACHIRUSATO) Mime-Version: 1.0 Content-Type: Text/Plain; charset=iso-2022-jp Content-Transfer-Encoding: 7bit X-Spam: no; 0.00; christophe:01 troestler:01 christophe:01 troestler:01 ocaml:01 printf:01 printf:01 compiler:01 unboxed:01 wrote:01 dmitry:01 caml-list:01 minor:01 umh:01 bely:01 On Wed, 1 Sep 2010 11:18:05 +0400, Dmitry Bely wrote: > > >> Some black magic is needed: > >> > >> let r = ref 0.0 in > >> for i = 0 to 1000_000_000 do r := float i done; > >> Printf.printf "%f\n" (!r +. 0.); > >> Printf.printf "words: %f\n" (Gc.stat ()).Gc.minor_words > > Do you have any idea why the optimizer needs that? It helps the compiler to figure out that “r” must be unboxed. See also http://caml.inria.fr/mantis/view.php?id=5133 C.