1

I use often array in my project. I just realize that for an out of bounds error in an assignment (e.g. a.(100) <- 5), if there is no catching exception, it will silently stop the execution.

I would like to know the place where the error is raised, once every error like occurs. One way to do it is to add try ... with ... around array operations, but obviously it is tedious and not good-looking...

Does anyone have a better idea?

Same logic for map operations. I notice that for find in map, if no binding exists, Not_found is raised, but if there is no try ... with ..., nothing will be explicitly shown. How can I make it explicitly shown systematically?

4

1 回答 1

0

使用调试符号“-g”编译程序并设置环境变量 OCAMLRUNPARAM=b。或使用 Printexc

谷歌是你的朋友: http ://www.mega-nerd.com/erikd/Blog/CodeHacking/Ocaml/exception_backtraces.html,http : //caml.inria.fr/pub/docs/manual-ocaml/libref/Printexc .html , ...

于 2013-08-24T06:42:30.480 回答