English version
Accueil     À propos     Téléchargement     Ressources     Contactez-nous    

Ce site est rarement mis à jour. Pour les informations les plus récentes, rendez-vous sur le nouveau site OCaml à l'adresse ocaml.org.

Browse thread
[Caml-list] Stack Overflow... (recursion in try-statement)
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2002-04-23 (22:55)
From: Oliver Bandel <oliver@f...>
Subject: Re: [Caml-list] Stack Overflow... (recursion in try-statement)

I have found a working version:

On Tue, 23 Apr 2002, Oliver Bandel wrote:

> Hello,
> why does an stack overflow-error occur here?
> let rec traversedir dir =
>           try ( [Unix.readdir dir] @ traversedir dir ) with
>           End_of_file -> [];;

It works with

 let rec traversedir dir =
           try ( traversedir dir @ [Unix.readdir dir] ) with
           End_of_file -> [];;

...but I have to add the recursive traversing-call
(if Unix.st_kind is a S_DIR, I have to open that
 dir and go into it too... so I may add the
 opendir/closedir-calls into the traversedir itself...)

But I'm wondering if I better should have a list as
an addtional parameter, on which I append with readdir.

Any design-hints are welcome.


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