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 UAA02140; Thu, 7 Jun 2001 20:20:11 +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 UAA02207 for ; Thu, 7 Jun 2001 20:20:10 +0200 (MET DST) Received: from web11902.mail.yahoo.com (web11902.mail.yahoo.com [216.136.172.186]) by concorde.inria.fr (8.11.1/8.10.0) with SMTP id f57IK8f03486 for ; Thu, 7 Jun 2001 20:20:08 +0200 (MET DST) Message-ID: <20010607182007.33358.qmail@web11902.mail.yahoo.com> Received: from [24.221.161.16] by web11902.mail.yahoo.com; Thu, 07 Jun 2001 11:20:07 PDT Date: Thu, 7 Jun 2001 11:20:07 -0700 (PDT) From: Tom _ Subject: Re: [Caml-list] OCaml Speed for Block Convolutions To: William Chesters , caml-list@inria.fr In-Reply-To: <15134.30731.137189.386800@beertje.william.bogus> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii 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. I don't see why. The compiler has full type information. All it may have to do is box up a return value. In any case, whether or not the compiler in the current implementation can or cannot do good type inference and may or may not be forced to box a floating point number, the two constructs mean something different to the programmer, and they behave differently. In particular "mutable x" can never be passed around as a reference, while "x = ref ..." can. If not anything else, that prevents the programmer from inadvertently inhibiting a compiler optimization by passing around a reference. Besides, the syntax is probably quite a bit more natural to imperative programmers anyway. Tom. __________________________________________________ Do You Yahoo!? Get personalized email addresses from Yahoo! Mail - only $35 a year! http://personal.mail.yahoo.com/ ------------------- Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr