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 TAA08754; Sun, 15 Aug 2004 19:05:18 +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 TAA08247 for ; Sun, 15 Aug 2004 19:05:17 +0200 (MET DST) Received: from mproxy.gmail.com (rproxy.gmail.com [64.233.170.194]) by concorde.inria.fr (8.12.10/8.12.10) with ESMTP id i7FH5GRM030079 for ; Sun, 15 Aug 2004 19:05:16 +0200 Received: by mproxy.gmail.com with SMTP id 77so52021rnl for ; Sun, 15 Aug 2004 10:05:15 -0700 (PDT) Received: by 10.38.96.19 with SMTP id t19mr175146rnb; Sun, 15 Aug 2004 10:05:15 -0700 (PDT) Message-ID: <83f599680408151005288b6bf9@mail.gmail.com> Date: Sun, 15 Aug 2004 10:05:15 -0700 From: Shishir Ramam Reply-To: Shishir Ramam To: caml-list@inria.fr Subject: [Caml-list] trouble w/ recursive let definitions. Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Miltered: at concorde with ID 411F97CC.001 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Loop: caml-list@inria.fr X-Spam: no; 0.00; 3.07:01 binaries:01 3.07:01 expr:01 exprn:01 expr:01 exprn:01 behave:01 namen:99 namen:99 bindings:01 ocaml:01 ocaml:01 int:01 rec:01 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk Hi, I might be missing something here, but recursive let definitions have me a little confused. The two cases below narrow down my problem. Why is case-2 invalid? A reading of the Ocaml User manual did not suggest that case 2 should be invalid. I have pasted the relevent section of the manual. I am using Ocaml 3.07+2 precompiled win32 binaries. Thanks in advance for any help. -shishir Case 1: ---------- let rec p1 s = p2 s and p2 s = print_string s;; This works fine. Case 2: ---------- let q0 i = print_int i; and rec q1 s = q2 s and q2 s = print_string s;; Characters 33-36: and rec q1 s = ^^^ Syntax error ------------------------------ >>From the User manual (3.07+2/win32) , Section 6.7.1 pg 109 Recursive definitions of names are introduced by let rec: let rec pattern1 = expr1 and . . . and patternn = exprn in expr The only difference with the let construct described above is that the bindings of names to values performed by the pattern-matching are considered already performed when the expressions expr1 to exprn are evaluated. That is, the expressions expr1 to exprn can reference identifiers that are bound by one of the patterns pattern1, . . . , patternn, and expect them to have the same value as in expr, the body of the let rec construct. The recursive definition is guaranteed to behave as described above if the expressions expr1 to exprn are function definitions (fun . . . or function . . .), and the patterns pattern1 . . . patternn are just value names, as in: let rec name1 = fun . . . and . . . and namen = fun . . . in expr This defines name1 . . . namen as mutually recursive functions local to expr. ------------------- 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