From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id DAA20867; Thu, 7 Jun 2001 03:50:29 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id DAA20931 for ; Thu, 7 Jun 2001 03:50:26 +0200 (MET DST) Received: from pauillac.inria.fr (pauillac.inria.fr [128.93.11.35]) by concorde.inria.fr (8.11.1/8.10.0) with ESMTP id f571oPL04731; Thu, 7 Jun 2001 03:50:25 +0200 (MET DST) Received: (from herbelin@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id DAA20850; Thu, 7 Jun 2001 03:50:24 +0200 (MET DST) From: Hugo Herbelin Message-Id: <200106070150.DAA20850@pauillac.inria.fr> Subject: Re: [Caml-list] OCaml Speed for Block Convolutions In-Reply-To: <15134.30731.137189.386800@beertje.william.bogus> from William Chesters at "Jun 6, 101 08:35:55 pm" To: williamc@paneris.org (William Chesters) Date: Thu, 7 Jun 2001 03:50:24 +0200 (MET DST) Cc: caml-list@inria.fr X-Mailer: ELM [version 2.4ME+ PL28 (25)] MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk William Chesters wrote: > Hugo Herbelin writes: > > Assume more generally that you can modify any local variable as in the > > (standard) following example: > > > > let fact (mutable n) = > > let mutable r = 1 in > > while n > 0 do > > r <- r * n; > > n <- n - 1 > > done; > > r > > This doesn't actually make life much easier for the compiler. On > 32-bit machines [see other thread!], `r' must be a reference (in the > C++ sense) to a heap object---64-bit float, plus header. In general > it is not safe to overwrite the float value in the heap, if it's > possible that other variables have been assigned to it. (unless floats > are assigned by value not by reference, but in that case you get heap > allocation at the time of assignment ...). To be boxed or not is not a property of the language but of the implementation. This means that the semantics for such a "x <- e" for boxed values (may be floats) can only be the same as for unboxed values, that is "assignment by value". This means that "x <- e", compared to "x.contents <- e", wouldn't avoid the heap allocation inherent to the boxing of floats, but would just avoid the initial allocation of an extra ref block and the subsequent indirections to set/get the value (assuming the cell is not already cached in a register what perhaps the compiler is able to do). Hugo ------------------- To unsubscribe, mail caml-list-request@inria.fr. Archives: http://caml.inria.fr