From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail1-relais-roc.national.inria.fr (mail1-relais-roc.national.inria.fr [192.134.164.82]) by walapai.inria.fr (8.13.6/8.13.6) with ESMTP id q3D9hKob001925 for ; Fri, 13 Apr 2012 11:43:20 +0200 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AlcFAAb0h0+CiAFm/2dsb2JhbABFpiCRVIEHggkBAQUnRwoRCxgJBBIPCQMCAQIBMxITBgIBAQ6HbgMLC7AHA4ldkVcEln2IRYZggmk X-IronPort-AV: E=Sophos;i="4.75,415,1330902000"; d="scan'208,217";a="153900769" Received: from leb.cs.unibo.it ([130.136.1.102]) by mail1-smtp-roc.national.inria.fr with ESMTP/TLS/ADH-AES256-SHA; 13 Apr 2012 11:43:14 +0200 Received: from ssl.cs.unibo.it (ssl.cs.unibo.it [127.0.0.1]) (Authenticated sender: hidden) by leb.cs.unibo.it (Postfix) with ESMTPSA id EF7FB2365 for ; Fri, 13 Apr 2012 11:43:13 +0200 (CEST) Message-ID: <4F87F535.8030705@cs.unibo.it> Date: Fri, 13 Apr 2012 11:43:17 +0200 From: Matthias Puech User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:11.0) Gecko/20120329 Thunderbird/11.0.1 MIME-Version: 1.0 To: caml-list@inria.fr References: <4F87EDFB.6090409@cs.unibo.it> In-Reply-To: Content-Type: multipart/alternative; boundary="------------080408050403000606060606" Subject: Re: [Caml-list] Printexc.register_printer without catch This is a multi-part message in MIME format. --------------080408050403000606060606 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8bit Ok so it seems Printexc is not the way to go... Can you make sense out of this sentence in catch's documentation then? "This function is deprecated: the runtime system is now able to print uncaught exceptions as precisely as|Printexc.catch|does" In the toplevel, exceptions are printed in a sensible way, i.e. their arguments is printed as far as it can go respecting abstract types: # type t = A | B;; # exception Bla of t;; # raise (Bla A);; Exception: Bla A. Also it honors my #install_printer when printing arguments. If I compile the same code, I get: Fatal error: exception Exc.Bla(0) It seems there is a very ad-hoc, type-unaware exception handler in compiled code (byterun/printexc.c:caml_format_exception?) that can't be changed and I was hoping Printexc would do that for me. It seems not; so, no other way to change the global catcher? Thanks, -m Le 04/13/2012 11:18 AM, Gabriel Scherer a écrit : > It seems Printexc.register_printer affects the other Printexc.* > functions, not the way the toplevel itself (or the runtime system more > generally) handles uncaught exceptions. > > # Printexc.register_printer begin function Not_found -> Some "hello" | > _ -> None end;; > - : unit = () > # (fun () -> raise Not_found) ();; > Exception: Not_found. > # Printexc.print (fun () -> raise Not_found) ();; > Uncaught exception: hello > Exception: Not_found. > > > On Fri, Apr 13, 2012 at 11:12 AM, Matthias Puech wrote: >> Hello, >> >> Is there a way to change printing of uncaught exceptions in the toplevel and >> in (native/bytecode, 3.12) compiled code without wrapping the whole code in >> a try ... with or in Printexc.catch? >> >> Printexc.catch's documentation says it is deprecated and that the runtime >> system should be able to print exceptions the way they were registered with >> Printexc.register_printer, yet >> >> # Printexc.register_printer begin function Not_found -> Some "hello" | _ -> >> None end;; >> # raise Not_found;; >> Exception: Not_found. >> >> (* I would expect it to respond [Exception: hello] *) >> >> Do I miss something here? >> Thanks in advance, >> -m >> >> -- >> Caml-list mailing list. Subscription management and archives: >> https://sympa-roc.inria.fr/wws/info/caml-list >> Beginner's list: http://groups.yahoo.com/group/ocaml_beginners >> Bug reports: http://caml.inria.fr/bin/caml-bugs >> > --------------080408050403000606060606 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Ok so it seems Printexc is not the way to go... Can you make sense out of this sentence in catch's documentation then?

"This function is deprecated: the runtime system is now able to print uncaught exceptions as precisely as Printexc.catch does"

In the toplevel, exceptions are printed in a sensible way, i.e. their arguments is printed as far as it can go respecting abstract types:

# type t = A | B;;
# exception Bla of t;;
# raise (Bla A);;
Exception: Bla A.

Also it honors my #install_printer when printing arguments.
If I compile the same code, I get:

Fatal error: exception Exc.Bla(0)

It seems there is a very ad-hoc, type-unaware exception handler in compiled code (byterun/printexc.c:caml_format_exception?) that can't be changed and I was hoping Printexc would do that for me. It seems not; so, no other way to change the global catcher?

Thanks,
    -m

Le 04/13/2012 11:18 AM, Gabriel Scherer a écrit :
It seems Printexc.register_printer affects the other Printexc.*
functions, not the way the toplevel itself (or the runtime system more
generally) handles uncaught exceptions.

# Printexc.register_printer begin function Not_found -> Some "hello" |
_ -> None end;;
- : unit = ()
# (fun () -> raise Not_found) ();;
Exception: Not_found.
# Printexc.print (fun () -> raise Not_found) ();;
Uncaught exception: hello
Exception: Not_found.


On Fri, Apr 13, 2012 at 11:12 AM, Matthias Puech <puech@cs.unibo.it> wrote:
Hello,

Is there a way to change printing of uncaught exceptions in the toplevel and
in (native/bytecode, 3.12) compiled code without wrapping the whole code in
a try ... with or in Printexc.catch?

Printexc.catch's documentation says it is deprecated and that the runtime
system should be able to print exceptions the way they were registered with
Printexc.register_printer, yet

# Printexc.register_printer begin function Not_found -> Some "hello" | _ ->
None end;;
# raise Not_found;;
Exception: Not_found.

(* I would expect it to respond [Exception: hello] *)

Do I miss something here?
Thanks in advance,
   -m

--
Caml-list mailing list.  Subscription management and archives:
https://sympa-roc.inria.fr/wws/info/caml-list
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
Bug reports: http://caml.inria.fr/bin/caml-bugs



--------------080408050403000606060606--