From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by yquem.inria.fr (Postfix) with ESMTP id DBF1ABB83 for ; Thu, 6 Jul 2006 17:37:09 +0200 (CEST) Received: from nf-out-0910.google.com (nf-out-0910.google.com [64.233.182.190]) by nez-perce.inria.fr (8.13.6/8.13.6) with ESMTP id k66FbBdZ019687 for ; Thu, 6 Jul 2006 17:37:11 +0200 Received: by nf-out-0910.google.com with SMTP id y25so237992nfb for ; Thu, 06 Jul 2006 08:37:09 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=BKu+qKZdN6wnR86qZBhUsxCu0N6MtSvMAK/Ho58QHAit11G+pJhsPohhHPNRoRHCqXCR4o/3VWDjQ9qB49veAD2pheGBaEByMYAzR0Dkx8cAHBmwcbujzZvIRLtxAiDuBfv+n2Qth1Yf0WCXlZe4bWUXvWp525ThC9zTD6QJrcQ= Received: by 10.78.185.7 with SMTP id i7mr258863huf; Thu, 06 Jul 2006 08:37:09 -0700 (PDT) Received: by 10.78.13.17 with HTTP; Thu, 6 Jul 2006 08:37:09 -0700 (PDT) Message-ID: Date: Thu, 6 Jul 2006 17:37:09 +0200 From: "Nicolas Pouillard" To: "Jonathan Roewen" Subject: Re: [Caml-list] A global exception handler... Cc: "Till Varoquaux" , OCaml In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <9d3ec8300607060748s18ad08c6v282af9bc795099c8@mail.gmail.com> X-j-chkmail-Score: MSGID : 44AD2E27.000 on nez-perce : j-chkmail score : X : 0/20 1 X-Miltered: at nez-perce with ID 44AD2E27.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; handler:01 camlp:01 handler:01 cmo:01 ocaml:01 struct:01 printf:01 printf:01 eprintf:01 eprintf:01 printexc:01 printexc:01 runtime:01 camlp:01 ocaml:01 X-Spam-Checker-Version: SpamAssassin 3.0.3 (2005-04-27) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.4 required=5.0 tests=DNS_FROM_RFC_ABUSE,RCVD_BY_IP autolearn=disabled version=3.0.3 On 7/6/06, Jonathan Roewen 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