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 HAA08970; Wed, 24 Apr 2002 07:25:01 +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 HAA08933 for ; Wed, 24 Apr 2002 07:25:00 +0200 (MET DST) Received: from smtp017.mail.yahoo.com (smtp017.mail.yahoo.com [216.136.174.114]) by nez-perce.inria.fr (8.11.1/8.11.1) with SMTP id g3O5OxP04160 for ; Wed, 24 Apr 2002 07:24:59 +0200 (MET DST) Received: from adsl-63-195-80-23.dsl.snfc21.pacbell.net (HELO aria.yahoo.com) (joelisp@63.195.80.23 with login) by smtp.mail.vip.sc5.yahoo.com with SMTP; 24 Apr 2002 05:24:58 -0000 Message-Id: <5.1.0.14.0.20020423222913.02ea04d0@pop.mail.yahoo.com> X-Sender: joelisp@pop.mail.yahoo.com X-Mailer: QUALCOMM Windows Eudora Version 5.1 Date: Tue, 23 Apr 2002 22:31:23 -0700 To: caml-list@inria.fr From: Charles Martin Subject: Re: [Caml-list] Stack Overflow... (recursion in try-statement) In-Reply-To: <20020424045225.GD2828@alan-schm1p> References: Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk >I think you stumbled on the good old "evaluation order is not specified" >thingy ... If the right hand side of the append is called before the >left hand side, it is not going to work. How about this code: > >let rec traversedir dir = > try > let d = Unix.readdir dir in > d :: (traversedir dir) > with > | End_of_file -> [] You are building a stack of exception handlers here as well... you might want to go with: let traversedir dir = let dd = ref [] in try while true do dd := Unix.readdir dir :: !dd done with End_of_file -> !dd Disclaimer: I didn't run this code :) _________________________________________________________ Do You Yahoo!? Get your free @yahoo.com address at http://mail.yahoo.com ------------------- 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