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 PAA20851; Wed, 24 Apr 2002 15:35:08 +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 PAA20904 for ; Wed, 24 Apr 2002 15:35:07 +0200 (MET DST) Received: from hirsch.in-berlin.de (hirsch.in-berlin.de [192.109.42.6]) by nez-perce.inria.fr (8.11.1/8.11.1) with ESMTP id g3ODZ6P14616 for ; Wed, 24 Apr 2002 15:35:06 +0200 (MET DST) Received: from hirsch.in-berlin.de (localhost [127.0.0.1]) by hirsch.in-berlin.de (8.12.1/8.12.1/Debian -2) with ESMTP id g3ODZ1TL020120 (version=TLSv1/SSLv3 cipher=EDH-RSA-DES-CBC3-SHA bits=168 verify=NOT); Wed, 24 Apr 2002 15:35:02 +0200 Received: (from uucp@localhost) by hirsch.in-berlin.de (8.12.1/8.12.1/Debian -2) with UUCP id g3ODZ1OL020109; Wed, 24 Apr 2002 15:35:01 +0200 X-Envelope-From: oliver@first.in-berlin.de X-Envelope-To: caml-list@inria.fr Received: from localhost (oliver@localhost) by first.in-berlin.de (8.7.6/8.7.3) with SMTP id PAA00877; Wed, 24 Apr 2002 15:22:06 +0200 Date: Wed, 24 Apr 2002 15:22:06 +0200 (MET DST) From: Oliver Bandel To: Warp cc: caml-list@inria.fr Subject: Re: [Caml-list] Stack Overflow... (recursion in try-statement) In-Reply-To: <004301c1eb2b$9f48e440$99da0e50@warp> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk On Wed, 24 Apr 2002, Warp wrote: > > why does an stack overflow-error occur here? > > > > let rec traversedir dir = > > try ( [Unix.readdir dir] @ traversedir dir ) with > > End_of_file -> [];; > > > > > > I have not tried it with very deep directories, so > > I did not expect such an error... > > > > What is the problem here? > > Perhaps he's looping because ".." is also a dir. > You should try to do some print to figure it out A chdir from "/" to ".." will set the pwd to "/". But the catalog-entries are not infenite. So this can not be the problem here, because I'm not really traversing the directory. My code only does give back the list of entries of a directory (I gave the wrong name: the name is for the whole function/problem, but I only solved the part of the problem: to get *all* entries of a directory). But you are right with your hint, that I have to take care of "." and ".." when really traversing the directory-structure and performing actions on "." and "..". E.g. renaming of "." and ".." is not working, and the jump to "." or ".." can cause problems (in that I ran with my C-version of the program, because I have not thought about that problem => possible bugs surely will be done... ;-)). In the case of my problem the explanation with expanding the terms (order of evaluation/expanding) is the key. Ciao, Oliver ------------------- 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