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 MAA26270; Sun, 31 Aug 2003 12:32:09 +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 MAA27474 for ; Sun, 31 Aug 2003 12:32:08 +0200 (MET DST) Received: from mail3.tpgi.com.au (mail.tpgi.com.au [203.12.160.59]) by nez-perce.inria.fr (8.11.1/8.11.1) with ESMTP id h7VAW6T06517 for ; Sun, 31 Aug 2003 12:32:06 +0200 (MET DST) Received: from 203-213-83-197-syd-ts15-2600.tpgi.com.au (203-213-83-197-syd-ts15-2600.tpgi.com.au [203.213.83.197]) by mail3.tpgi.com.au (8.11.6/8.11.6) with ESMTP id h7VAVw718896; Sun, 31 Aug 2003 20:31:59 +1000 Subject: Re: [Caml-list] beginner question about tail recursion From: skaller Reply-To: skaller@ozemail.com.au To: Matt Gushee Cc: caml-list@pauillac.inria.fr In-Reply-To: <20030831063334.GA3405@swordfish> References: <20030831063334.GA3405@swordfish> Content-Type: text/plain Message-Id: <1062325909.15303.8.camel@localhost.localdomain> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.2.2 (1.2.2-4) Date: 31 Aug 2003 20:31:50 +1000 Content-Transfer-Encoding: 7bit X-Loop: caml-list@inria.fr X-Spam: no; 0.00; caml-list:01 recursion:01 ozemail:01 gushee:01 rec:01 wrote:03 recursive:03 tail:03 tail:03 let:04 let:04 quite:06 beginner:08 think:11 cross:13 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk On Sun, 2003-08-31 at 16:33, Matt Gushee wrote: > 2. The recursive call can't be within a 'try' block. I think that is not quite the correct rule, the rule should be that the call can't cross a try block boundary. For example: let g x = let y = try h x with _ -> [] in g y This example _contains_ a try block. let f x = try let g x = h x in g x with _ -> ... this example is _contained in_ a try block. Both have tail calls to g. But in this example: 1 let rec readlines chnl = 2 try 3 let line = input_line chnl in 4 line :: (readlines chnl) 5 with End_of_file -> [] the call of readlines _crosses_ a try block boundary. ------------------- 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