Browse thread
[Caml-list] A global exception handler...
-
Jonathan Roewen
-
Till Varoquaux
-
Nicolas Pouillard
-
Jonathan Roewen
- Nicolas Pouillard
-
Jonathan Roewen
-
Nicolas Pouillard
-
Till Varoquaux
[
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: | 2006-07-06 (15:37) |
From: | Nicolas Pouillard <nicolas.pouillard@g...> |
Subject: | Re: [Caml-list] A global exception handler... |
On 7/6/06, Jonathan Roewen <jonathan.roewen@gmail.com> wrote: > > $ camlp4o global_handler.cmo -printer OCaml global_handler_test.ml > > try > > let module Main = > > struct > > open Format > > let f1 x = printf "f1 %d@." x > > let f2 x = printf "f2 %f@." x > > let f3 x = printf "f3 %s@." x > > let _ = f1 1 > > let _ = f2 1.1 > > let _ = f3 "1.1.1" > > let _ = raise (Failure "test") > > let global_handler e = > > (* Note that I need to give the complete name for eprintf since > > Format is not opened in the new environment of global_handler. *) > > Format.eprintf "global_handler: %s@." (Printexc.to_string e) > > end > > in () > > with > > | e -> > > (fun e -> Format.eprintf "global_handler: %s@." (Printexc.to_string e)) e > > > > Ah, defining a module inside a function is a neat trick! I didn't > think of that. Well, I guess it couldn't hurt to do that with all the > modules which could cause trouble at runtime... > > Can I build the new camlp4 with 3.09.2 tools? > In fact camlp4 will be part of OCaml 3.10 distribution, so it's better to try it directly like that, instead of mixing them with 3.09.2. -- Nicolas Pouillard