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 1F704BB83 for ; Thu, 6 Jul 2006 16:48:27 +0200 (CEST) Received: from nf-out-0910.google.com (nf-out-0910.google.com [64.233.182.189]) by nez-perce.inria.fr (8.13.6/8.13.6) with ESMTP id k66EmSZi011279 for ; Thu, 6 Jul 2006 16:48:28 +0200 Received: by nf-out-0910.google.com with SMTP id y25so224503nfb for ; Thu, 06 Jul 2006 07:48:26 -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=nohGpcIjR1pieiMGDeFuMdhoG/FqcL0FlmiXt3mX3aKBYp2zcUj8gwxuV78EKnq0QRAhhYuIZmnIhs0TXmVuYhX93QwGQu/R9EHhWNTKMOo/R0ZRjObB5PSwtm3skmM79/GpMr83MI/A2NVcVGLkHGPcu1yBQh3UzWExdxAoirA= Received: by 10.78.178.5 with SMTP id a5mr238260huf; Thu, 06 Jul 2006 07:48:26 -0700 (PDT) Received: by 10.78.149.4 with HTTP; Thu, 6 Jul 2006 07:48:26 -0700 (PDT) Message-ID: <9d3ec8300607060748s18ad08c6v282af9bc795099c8@mail.gmail.com> Date: Thu, 6 Jul 2006 16:48:26 +0200 From: "Till Varoquaux" To: "Jonathan Roewen" Subject: Re: [Caml-list] A global exception handler... Cc: OCaml In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline References: X-j-chkmail-Score: MSGID : 44AD22BC.000 on nez-perce : j-chkmail score : X : 0/20 1 X-Miltered: at nez-perce with ID 44AD22BC.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; handler:01 handler:01 toplevel:01 camlp:01 toplevel:01 camlp:01 wrote:01 caml-list:01 exception:01 exception:01 rewrite:01 defined:02 defined:02 expressions:04 expressions:04 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: > Hi, > > Is it possible to register a global exception handler? > > I suppose I could just nest everything inside one giant function if I > really had to, but I like my toplevel expressions ;-) > CamlP4 might come in handy here. I'm guessing you could rewrite your program so that all your toplevel expressions are in one main () function using camlp4. It would have some limitations though: for instance your exception handler could not use anything defined in main (unless you where using references). I'm guessing it's not so bad because whatever happens you cannot have a global exception handler relying to much on stuff defined in your programm. > Jonathan