From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Delivered-To: caml-list@yquem.inria.fr Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by yquem.inria.fr (Postfix) with ESMTP id 8D83DBBFB for ; Tue, 21 Jun 2005 11:07:41 +0200 (CEST) Received: from pauillac.inria.fr (pauillac.inria.fr [128.93.11.35]) by concorde.inria.fr (8.13.0/8.13.0) with ESMTP id j5L97f03006175 for ; Tue, 21 Jun 2005 11:07:41 +0200 Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id LAA27923 for ; Tue, 21 Jun 2005 11:07:40 +0200 (MET DST) Received: from yquem.inria.fr (yquem.inria.fr [128.93.8.37]) by concorde.inria.fr (8.13.0/8.13.0) with ESMTP id j5L97e5u006172; Tue, 21 Jun 2005 11:07:40 +0200 Received: by yquem.inria.fr (Postfix, from userid 18041) id 0D085BBFB; Tue, 21 Jun 2005 11:07:40 +0200 (CEST) Date: Tue, 21 Jun 2005 11:07:40 +0200 To: Luca Pascali Cc: caml-list@inria.fr Subject: Re: [Caml-list] exception Failure and failwith Message-ID: <20050621090740.GA10021@yquem.inria.fr> References: <42B7D0FD.5090305@barettadeit.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <42B7D0FD.5090305@barettadeit.com> User-Agent: Mutt/1.3.28i From: luc.maranget@inria.fr (Luc Maranget) X-Miltered: at concorde with ID 42B7D8DD.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Miltered: at concorde with ID 42B7D8DC.001 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; caml-list:01 failwith:01 maranget:01 maranget:01 failwith:01 pervasives:01 ocaml:01 checker:01 defines:01 compiler:01 'option':01 constructors:01 pervasives:01 ocaml's:01 ocaml's:01 X-Spam-Checker-Version: SpamAssassin 3.0.2 (2004-11-16) on yquem.inria.fr X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=disabled version=3.0.2 X-Spam-Level: > Hi everyone. > > I've ran into a situation and I need a little explanation. > > It's all about the failwith function of pervasives (that simply raises > an exception Failure of string). > Normally, that exception can be cought by means of a try...with using as > clause something like > | Failure s -> ..... > > That's good. > But what if I define something (another exception like module Stream > does), a constructor (like I did) with the name Failure? > > Obviously the Ocaml type checker will make all controls with the new > definition of Failure (starting from that point). > But what if I want to catch the Failure exception? :-/ > It seems that no module defines it, so I did not find any way to > identify the exception. > > Thanks to everyone > Luca > > -- Failure is considerd 'internal' (or built-in, or predefined) by the compiler. The same applies for instance to the 'option' type constructors None and Some. Have a look at the manual You could have expected that 'Failure' is defined in standard library (eg in module Pervasives) but it is not the case. So the answer is: tou can't. If you shadow OCaml's Failure by your definition, then you have no longer access to OCaml's Failure. -- Luc Maranget