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 KAA11954; Fri, 8 Jun 2001 10:25:27 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id KAA11966 for ; Fri, 8 Jun 2001 10:25:25 +0200 (MET DST) Received: from cs.huji.ac.il (cs.huji.ac.il [132.65.16.10]) by nez-perce.inria.fr (8.11.1/8.10.0) with ESMTP id f588POL13040 for ; Fri, 8 Jun 2001 10:25:25 +0200 (MET DST) Received: from zigzag.cs.huji.ac.il ([132.65.208.204] ident=root) by cs.huji.ac.il with esmtp (Exim 3.22 #1) id 158Ha7-0005if-00; Fri, 08 Jun 2001 11:25:23 +0300 Received: (from orodeh@localhost) by zigzag.cs.huji.ac.il (8.9.3/1.1c) id LAA26303; Fri, 8 Jun 2001 11:25:23 +0300 Date: Fri, 8 Jun 2001 11:25:22 +0300 (IDT) From: Ohad Rodeh To: Jacques Garrigue cc: tom7ca@yahoo.com, williamc@paneris.org, caml-list@inria.fr Subject: Re: [Caml-list] let mutable (was OCaml Speed for Block Convolutions) In-Reply-To: <20010608084947C.garrigue@kurims.kyoto-u.ac.jp> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk I don't mean to barge into an open door here, but the discussion here is about escape analysis. This certainly does not require the new "mutable" syntax. My personal opinion is that Caml has enough syntax as it is (try using/modifying the OCaml mly files as an exercise ...). In any case, escape analysis a clever optimization allowing some heap allocated objects to be allocated on the run-time stack. The MLkit takes escape analysis into the extrem, using regions. Java compilers also use escape analysis to reduce heap allocation. Since we are already on the "with list" thread, I'd like to add my own wish. I'm going to teach the "Purely Functional Data Structures" book (Chris Okasaki) as a course next semester. To do the real nifty stuff, you need to have polymorphic recursion supported by the compiler. Can this be added to the next release? Ohad. On Fri, 8 Jun 2001, Jacques Garrigue wrote: > About the introduction of a let mutable construct, > Tom _ wrote > > > 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. > > Not exactly, the compiler may still need to build a reference. > > let mutable x = 0 in > List.iter (fun y -> x <- x+y) l; > x > > Since x has tobe modified in a function called by iter, it must be > wrapped into an actual reference cell. > > As the compiler already does a good job at unboxing only locally used > references, let mutable would only be some syntactic sugar (with > exactly the same typing as a reference). > > > Besides, the syntax is probably quite a bit more > > natural to imperative programmers anyway. > > This is actually the only argument for let mutable. > I would also like such a construct, but I don't know whether its worth > it. Thereal question is whether let mutable should be allowed at > toplevel, with problems for both answers. > > Cheers, > > Jacques Garrigue > ------------------- > Bug reports: http://caml.inria.fr/bin/caml-bugsFAQ: http://caml.inria.fr/FAQ/ > To unsubscribe, mail caml-list-request@inria.frArchives: http://caml.inria.fr > ------------------- 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