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: -- (:)
From: Charles Martin <joelisp@y...>
Subject: Re: [Caml-list] Stack Overflow... (recursion in try-statement)

>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 address at

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