[
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: | Xavier Leroy <Xavier.Leroy@i...> |
| Subject: | Re: Newbies question |
> The following function does not compile, since the compiler thinks it has
> the wrong return type:
You've already received plenty of explanations on what's going on.
Let me just add one easy way to work around this: just have your "try"
construct return () in all cases. Like this:
> let read_res file : ('a * 'b) list =
> let final_result = ref [] in
> let fd = open_in file in
> begin try
> let lexbuf = Lexing.from_channel fd in
> while true do
> let result = Parseres.main Lexres.token lexbuf in
> final_result := result :: !final_result
> done
> with
> Lexres.Eof -> () (* this is the "normal" loop exit *)
> | Parsing.Parse_error ->
> close_in fd; printf "ERROR: Ressourcen Datei fehlerhaft\n";
> exit (-1)
> end;
> close_in fd; !final_result
- Xavier Leroy