Browse thread
Question about try.. with
-
christian konrad
- Jon Harrop
-
Jacques Garrigue
- christian konrad
[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| From: | christian konrad <konrad@i...> |
| Subject: | Re: [Caml-list] Question about try.. with |
Thanks for all those hints. For the future I will use the beginners list, thank you. But that seams really strange not to have a strictly defined order of evaluation. Isn't that really bad if one would like to do some tail recursion to get it compiled without recursion but as a loop? Thanks and cheers, Chris Jacques Garrigue wrote: >From: christian konrad <konrad@in.tum.de> > > > >>I'm doing that: >> >>let _ = >> try >> let infile = open_in !filename in >> let rec readIn () = >> try >> (input_line infile) ^ readIn(); >> with ee -> ""; >> in >> print_string(readIn () ); >> "good"; >> with e -> "";; >> >>So why don't I get any output at all? Doesn't "with" erease the raised >>Exception? >> >> > >Because you assume wrongly that input_line will be called before the >recursive call to readIn. Nothing in the ocaml specification says so >(evaluation order is left undefined.) In practice the rightmost call >is done first, which is the recursive call here, but you shouldn't >depend on it either. >By the way, it is a bad idea to catch all exceptions. ee should be >End_of_file and e should be Sys_error _. > >Jacques Garrigue > > >