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 UAA05361; Wed, 15 Jan 2003 20:15:53 +0100 (MET) 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 UAA05218 for ; Wed, 15 Jan 2003 20:15:52 +0100 (MET) Received: from mg.ihep.su (mg.ihep.su [194.190.161.38]) by nez-perce.inria.fr (8.11.1/8.11.1) with ESMTP id h0FJFpv16328 for ; Wed, 15 Jan 2003 20:15:51 +0100 (MET) Received: by mg.ihep.su (Postfix, from userid 65436) id 42D65B5999; Wed, 15 Jan 2003 22:15:51 +0300 (MSK) Received: from ontil.ihep.su (ontil.ihep.su [194.190.161.63]) by mg.ihep.su (Postfix) with ESMTP id 367B8B5995 for ; Wed, 15 Jan 2003 22:15:49 +0300 (MSK) Received: by ontil.ihep.su (Postfix, from userid 1001) id 93D8567AB; Wed, 15 Jan 2003 22:15:48 +0300 (MSK) Received: from localhost (localhost [127.0.0.1]) by ontil.ihep.su (Postfix) with ESMTP id 908A967AA for ; Wed, 15 Jan 2003 22:15:48 +0300 (MSK) Date: Wed, 15 Jan 2003 22:15:48 +0300 (MSK) From: Vitaly Lugovsky To: caml-list@inria.fr Subject: [Caml-list] let rec Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk For a closure-driven "compilers" I have to use for a recursion something like this: let xprs = ref (fun _ -> Lnil) in let f (il,al,ht) = let il2 = Array.make (n2+1) Lnil in acopy il il2; Array.iteri (fun i x -> il2.(all.(i)) <- x) al; !xprs (il2,anul,ht) in xprs := (Hashtbl.replace ht name (CTfun(f)); (* Insert f into the env2 environment *) compile_exprs env2 exprs); f It's not so funny. Why I can't write it using let rec: let rec f (il,al,ht) = let il2 = Array.make (n2+1) Lnil in acopy il il2; Array.iteri (fun i x -> il2.(all.(i)) <- x) al; xprs (il2,anul,ht) and xprs = (Hashtbl.replace ht name (CTfun(f)); compile_exprs env2 exprs) in f Sure, let rec construction should be much less restrictive. And, another one question: does ocaml compiler really eliminates unused variables from the closure environment? ------------------- To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ Beginner's list: http://groups.yahoo.com/group/ocaml_beginners