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 RAA15853; Wed, 7 May 2003 17:16:51 +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 RAA15972 for ; Wed, 7 May 2003 17:16:49 +0200 (MET DST) Received: from opus.davidb.org (66-75-152-1.san.rr.com [66.75.152.1]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id h47FGmH16739 for ; Wed, 7 May 2003 17:16:48 +0200 (MET DST) Received: from davidb by opus.davidb.org with local (Exim 3.31 #1 (Debian)) id 19DQeJ-0005gz-00; Wed, 07 May 2003 08:16:03 -0700 Date: Wed, 7 May 2003 08:16:03 -0700 From: David Brown To: Hal Daume III Cc: Neel Krishnaswami , "caml-list@inria.fr" Subject: Re: [Caml-list] why the "rec" in "let rec"? Message-ID: <20030507151603.GA21844@opus.davidb.org> References: <16057.7459.42552.45637@h00045a4799d6.ne.client2.attbi.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.4i X-Spam: no; 0.00; caml-list:01 disallow:01 bug:01 idioms:01 wrappers:01 debugging:01 bindings:01 0700,:01 mutable:01 rec:01 silly:02 dave:03 wrote:03 variable:03 let:04 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk On Wed, May 07, 2003 at 07:57:13AM -0700, Hal Daume III wrote: > > let f x = .. > > let f x = f x > > is to simply disallow bindings like this. I would think that they're > almost always a bug. Especially if the first definition appears at the > top of your file and the second (perhaps you forgot the "rec" and the body > is actually long) appears at the bottom. Likely it would turn out to be a > type error anyway, but why risk it? > > Anyway, I think the question was more along the lines of "why let the > programmer do something like this." I cannot answer that. I hope it doesn't get disabled. There are some very common idioms that use this type of declaration. let ... = let a = ... a ... in let a = ... a ... in let a = ... a ... in This way, you can build up the value of a, almost like they were assignments, but without the problems associated with mutable values. It would be silly to have to keep thinking of new names for the variable each time you did this. I have also made wrappers for functions for debugging purposes, and found it very convenient to just be able to call the old definition. Dave Brown ------------------- 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