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.0 required=5.0 tests=AWL 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 240DCBC6C for ; Thu, 31 Jan 2008 15:09:38 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AgAAAMJloUfAXQImh2dsb2JhbACQKwEBAQgKKYEUmGA X-IronPort-AV: E=Sophos;i="4.25,285,1199660400"; d="scan'208";a="6781195" Received: from discorde.inria.fr ([192.93.2.38]) by mail2-smtp-roc.national.inria.fr with ESMTP; 31 Jan 2008 15:09:38 +0100 Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by discorde.inria.fr (8.13.6/8.13.6) with ESMTP id m0VE9bw1002665 (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=OK) for ; Thu, 31 Jan 2008 15:09:37 +0100 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Ao8CAMJloUfBAkMt/2dsb2JhbACRfZhg X-IronPort-AV: E=Sophos;i="4.25,285,1199660400"; d="scan'208";a="6781193" Received: from vega.fmf.uni-lj.si (HELO postar.fmf.uni-lj.si) ([193.2.67.45]) by mail2-smtp-roc.national.inria.fr with ESMTP; 31 Jan 2008 15:09:37 +0100 Received: from localhost (unknown [192.168.5.1]) by postar.fmf.uni-lj.si (Postfix) with ESMTP id BF4802F1CF4; Thu, 31 Jan 2008 15:09:36 +0100 (CET) X-Virus-Scanned: amavisd-new at spam.fmf.uni-lj.si Received: from postar.fmf.uni-lj.si ([192.168.5.5]) by localhost (spam.fmf.uni-lj.si [192.168.5.1]) (amavisd-new, port 10024) with ESMTP id a-N9F+Xm9Mud; Thu, 31 Jan 2008 15:09:36 +0100 (CET) Received: from [193.2.67.88] (unknown [193.2.67.88]) by postar.fmf.uni-lj.si (Postfix) with ESMTP id 13F062F1CEE; Thu, 31 Jan 2008 15:09:16 +0100 (CET) Message-ID: <47A1D68B.70700@fmf.uni-lj.si> Date: Thu, 31 Jan 2008 15:09:15 +0100 From: Andrej Bauer Reply-To: Andrej.Bauer@andrej.com User-Agent: Thunderbird 2.0.0.6 (X11/20071022) MIME-Version: 1.0 To: =?ISO-8859-2?Q?B=FCnzli_Daniel?= Cc: Till Varoquaux , caml-list List Subject: Re: [Caml-list] [OSR] Exceptionless error management References: <9d3ec8300801310157r77b86fc0k80f40b1df36091c2@mail.gmail.com> <0640C30E-07B5-4885-AC38-671755BB79AA@erratique.ch> In-Reply-To: <0640C30E-07B5-4885-AC38-671755BB79AA@erratique.ch> Content-Type: text/plain; charset=ISO-8859-2; format=flowed Content-Transfer-Encoding: 8bit X-Miltered: at discorde with ID 47A1D6A1.000 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; andrej:01 andrej:01 bunzli:01 runtime:01 wrote:01 exception:01 assert:01 caml-list:01 functions:01 exceptions:01 match:02 checking:02 apis:03 library:03 let:03 Bünzli Daniel wrote: > let find map k = match Map.find map k with Some v -> v | None -> assert > false I have become to prefer option types as return values (as opposed to exceptions), but I admit it can be annoying to always consider both possibilities, especially if you know that "None" won't happen. If the library only provides "find" that returns an option type, the above solution gets around constant checking. But how much runtime overhead does it cause? Has anyone measured that? What is wrong with having two functions? With a bit of imagination, we can give them reasonable names, e.g., get and search. Everybody can guess which one returns the option type and which one throws an exception, right? Throwing out functionality on the grounds that it "clutters APIs" doesn't sound like a good idea to me. Throwing out bells and whistles is another matter. Andrej