caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: luc.maranget@inria.fr (Luc Maranget)
To: Luca Pascali <luca@barettadeit.com>
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] exception Failure and failwith
Date: Tue, 21 Jun 2005 11:07:40 +0200	[thread overview]
Message-ID: <20050621090740.GA10021@yquem.inria.fr> (raw)
In-Reply-To: <42B7D0FD.5090305@barettadeit.com>

> 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


  reply	other threads:[~2005-06-21  9:07 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-06-21  8:34 Luca Pascali
2005-06-21  9:07 ` Luc Maranget [this message]
2005-06-21 11:15   ` [Caml-list] " Luca Pascali
2005-06-21 11:34     ` Luc Maranget
2005-06-21 18:23       ` sejourne_kevin
2005-06-21 18:55       ` William Lovas
2005-06-23  8:04         ` Luca Pascali
2005-06-21  9:30 ` Julien Signoles

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20050621090740.GA10021@yquem.inria.fr \
    --to=luc.maranget@inria.fr \
    --cc=caml-list@inria.fr \
    --cc=luca@barettadeit.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).