[
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: | 2005-06-21 (09:07) |
From: | luc.maranget@i... |
Subject: | Re: [Caml-list] exception Failure and failwith |
> 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 <http://caml.inria.fr/pub/docs/manual-ocaml/manual033.html#htoc249> 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