Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

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-24 (10:45)
From: John Prevost <visigoth@c...>
Subject: Re: [Caml-list] Stack Overflow... (recursion in try-statement)
>>>>> "ob" == Oliver Bandel <> writes:

    ob> It works with

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

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

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

    ob> Any design-hints are welcome.

One gotcha is that try <tail-call> with ... blocks aren't tail
recursive.  So if you do that, you'll have to organize the code
slightly differently to make your tail call work.

To unsubscribe, mail Archives:
Bug reports: FAQ:
Beginner's list: