From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.5 required=5.0 tests=DNS_FROM_RFC_ABUSE autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by yquem.inria.fr (Postfix) with ESMTP id A5910BC69 for ; Wed, 24 Oct 2007 08:41:25 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AgAAANqFHkfUGyojimdsb2JhbACBWox/AQEBCAQGEREHgSc X-IronPort-AV: E=Sophos;i="4.21,322,1188770400"; d="scan'208";a="3540508" Received: from smtp5-g19.free.fr ([212.27.42.35]) by mail2-smtp-roc.national.inria.fr with ESMTP; 24 Oct 2007 08:41:25 +0200 Received: from smtp5-g19.free.fr (localhost.localdomain [127.0.0.1]) by smtp5-g19.free.fr (Postfix) with ESMTP id 034D63F6174 for ; Wed, 24 Oct 2007 08:41:25 +0200 (CEST) Received: from Llea.celt.neu (ron34-3-82-236-236-194.fbx.proxad.net [82.236.236.194]) by smtp5-g19.free.fr (Postfix) with ESMTP id D25523F614C for ; Wed, 24 Oct 2007 08:41:24 +0200 (CEST) Received: from Llea.celt.neu (localhost [127.0.0.1]) by Llea.celt.neu (8.14.1/8.13.8) with ESMTP id l9O6jf37032816 for ; Wed, 24 Oct 2007 08:45:41 +0200 (CEST) (envelope-from michael.le_barbier@laposte.net) Received: (from michael@localhost) by Llea.celt.neu (8.14.1/8.13.8/Submit) id l9O6jf5M032815; Wed, 24 Oct 2007 08:45:41 +0200 (CEST) (envelope-from michael.le_barbier@laposte.net) X-Authentication-Warning: Llea.celt.neu: michael set sender to michael.le_barbier@laposte.net using -f To: caml-list@yquem.inria.fr Subject: Preferred use of Invalid_argument and Failure From: michael.le_barbier@laposte.net (=?iso-8859-1?Q?Micha=EBl?= Le Barbier) Date: Wed, 24 Oct 2007 08:45:41 +0200 Message-ID: <867ildqacq.fsf@Llea.celt.neu> User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.1 (berkeley-unix) MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable X-Spam: no; 0.00; blit:01 advices:01 cheers:01 exception:01 exception:01 functions:01 functions:01 exceptions:01 exceptions:01 undefined:01 undefined:01 interfaces:01 interfaces:01 modules:02 modules:02 Hi, I am working on a library, I want the interfaces to look like standard library modules interfaces. From the standard library modules, it is usually possible to tell if fonction should be called `of'_string, `from'_string, etc. Considering exceptions, the situation is not so clear to me, and I would be glad to get a piece of advice or your feelings to help me towards a consistant use of these two exceptions. Small discussion: Let's quote the manual (release 3.09): exception Invalid_argument of string Exception raised by library functions to signal that the given arguments do not make sense. exception Failure of string Exception raised by library functions to signal that they are undefined on the given arguments. It seems to me that Invalid_argument is a sort of specialisation of Failure. A general rule that emerges from standard library modules is that: * when a function can tell a priori it's undefined on its arguments (exemple: String.blit) it should raise Invalid_argument; * when a function must try to compute an answer before it turns out there is no answer, it raises Failure (let's say you try to solve a singular system). However this general rule is not strictly followed by standard library modules. Again, I would be glad to get advices of discipline in using theses two exceptions. What works for you? --=20 Cheers, Micha=EBl