English version
Accueil     À propos     Téléchargement     Ressources     Contactez-nous    

Ce site est rarement mis à jour. Pour les informations les plus récentes, rendez-vous sur le nouveau site OCaml à l'adresse ocaml.org.

Browse thread
Question about float refs.
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Ethan Burns <burns.ethan@g...>
Subject: Re: [Caml-list] Re: Question about float refs.
On Wed, Sep 1, 2010 at 4:31 AM, Fabrice Le Fessant
<fabrice.le_fessant@inria.fr> wrote:
> If you replace (!r +. 0.) by (!r), you are passing the content of the
> reference as an argument to the function. Function arguments are not
> unboxed in ocamlopt, so the compiler sees a boxed occurrence of the
> float, and so must allocate it. The compiler could decide to have the
> float both as boxed and unboxed values, but since the reference is
> modified in the loop, there would be a risk of inconsistency, and so the
> compiler decides to have only a boxed value, and so the loop is much
> slower since it has to allocate the float at each iteration (the
> reference itself is probably not allocated).

Is there a reason that it can not decide to leave the float unboxed
until right before the Printf.printf call?  This way it would be
modified in the loop without any allocations and then would be placed
in a box only when the box is finally needed.