From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from weis@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id UAA19651 for caml-redistribution; Mon, 27 Jul 1998 20:31:51 +0200 (MET DST) 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 VAA27060 for ; Sat, 25 Jul 1998 21:06:43 +0200 (MET DST) Received: from fritz.traverse.net (oliverhome.cablezone.com [207.140.231.102]) by nez-perce.inria.fr (8.8.7/8.8.7) with ESMTP id VAA22819 for ; Sat, 25 Jul 1998 21:06:41 +0200 (MET DST) Received: from oliver by fritz.traverse.net with local (Exim 1.90 #1) for caml-list@inria.fr id 0z09eQ-00007g-00; Sat, 25 Jul 1998 15:06:38 -0400 Subject: Let rec trouble To: caml-list@inria.fr Date: Sat, 25 Jul 1998 15:06:38 -0400 (EDT) From: "Christopher Oliver" X-Mailer: ELM [version 2.4 PL25 PGP3 *ALPHA*] MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Message-Id: Sender: weis I'm having trouble with the syntax of let rec. Consider the following program for computing Van der Waerden's bound: open Num open Nat open Big_int open Ratio let rec n k l = let rec m i = if i =/ Int 0 then Int 1 else Int 2 */ (m (pred_num i)) */ (n (k **/ (m (pred_num i))) (pred_num l)) in if l =/ Int 2 then succ_num k else m k;; print_string (string_of_num (n (Int 3) (Int 3)));; I would like to restrict the lexical scope of 'n' by replacing the first double semicolon with 'in.' I nest m precisely to capture k and l in m's lexical environment. Why is this use forbidden? I.e. Why shouldn't I be able to write: let rec n k l = let rec m i = if i =/ Int 0 then Int 1 else Int 2 */ (m (pred_num i)) */ (n (k **/ (m (pred_num i))) (pred_num l)) in if l =/ Int 2 then succ_num k else m k in print_string (string_of_num (n (Int 3) (Int 3)));; I would prefer not to define a top level symbol, and this seems an inconsistancy. Am I missing something? -- Christopher Oliver Traverse Internet Systems Coordinator 223 Grandview Pkwy, Suite 108 oliver@traverse.net Traverse City, Michigan, 49684 let magic f = fun x -> x and more_magic n f = fun x -> f ((n f) x);;