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=1.0 required=5.0 tests=AWL,SPF_NEUTRAL autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail1-relais-roc.national.inria.fr (mail1-relais-roc.national.inria.fr [192.134.164.82]) by yquem.inria.fr (Postfix) with ESMTP id D76B5BC6C for ; Thu, 31 Jan 2008 21:03:59 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AgAAAPe4oUfAXQInh2dsb2JhbACQIgEBAQgKKZd3h3E X-IronPort-AV: E=Sophos;i="4.25,286,1199660400"; d="scan'208";a="7487147" Received: from concorde.inria.fr ([192.93.2.39]) by mail1-smtp-roc.national.inria.fr with ESMTP; 31 Jan 2008 21:03:59 +0100 Received: from mail4-relais-sop.national.inria.fr (mail4-relais-sop.national.inria.fr [192.134.164.105]) by concorde.inria.fr (8.13.6/8.13.6) with ESMTP id m0VK3xwi030958 (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=OK) for ; Thu, 31 Jan 2008 21:03:59 +0100 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AgAAAEO4oUdC+Vq0mGdsb2JhbACQIgEBAQEBBgQGBwoWmBGHcQ X-IronPort-AV: E=Sophos;i="4.25,286,1199660400"; d="scan'208";a="22030929" Received: from ik-out-1112.google.com ([66.249.90.180]) by mail4-smtp-sop.national.inria.fr with ESMTP; 31 Jan 2008 21:03:58 +0100 Received: by ik-out-1112.google.com with SMTP id b32so87754ika.1 for ; Thu, 31 Jan 2008 12:03:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:cc:message-id:from:to:in-reply-to:content-type:content-transfer-encoding:mime-version:subject:date:references:x-mailer:sender; bh=3A0HvpVuDZlhc/aZx+QbTRGxXZyjRmasdtvtWZoMcVA=; b=N9/OJdcqKYCHTWSRtOGYjXIcZm/19gz0xB+mbvJ4dyC9VjZZW4S3BHnKIxU87aMc/+DAWaSj0GZRFFf10SaC1dPJy/jvaQ+rYnCZp2pY2WHtiO617ez02xvEr9R1ZaRFAckluiyKZ47R0cyNpVKOQEP7Vmytrgx7OpamSZdl28U= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=cc:message-id:from:to:in-reply-to:content-type:content-transfer-encoding:mime-version:subject:date:references:x-mailer:sender; b=dbqAwHhncJ6skJfpbOE1YC6by4Yw9OFiy66reFKzqZec7kBKjU696m30fMoBTIM8z0BoFMHKkM9fTgJbDfpNyUgR040yQ4xwfde9xs+XqZa9aKiKnVWjpAN340hq8b0iq1lhDd26XspFrHHyFCSLgiwoSHFRMhYfQOv4t1w+l0Q= Received: by 10.78.170.17 with SMTP id s17mr4221995hue.35.1201809837329; Thu, 31 Jan 2008 12:03:57 -0800 (PST) Received: from ?192.168.1.58? ( [85.2.50.200]) by mx.google.com with ESMTPS id 6sm283736nfv.14.2008.01.31.12.03.56 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 31 Jan 2008 12:03:56 -0800 (PST) Cc: caml-list List Message-Id: From: =?ISO-8859-1?Q?B=FCnzli_Daniel?= To: Andrej.Bauer@andrej.com In-Reply-To: <47A1D68B.70700@fmf.uni-lj.si> Content-Type: text/plain; charset=ISO-8859-1; format=flowed; delsp=yes Content-Transfer-Encoding: quoted-printable Mime-Version: 1.0 (Apple Message framework v915) Subject: Re: [Caml-list] [OSR] Exceptionless error management Date: Thu, 31 Jan 2008 21:03:58 +0100 References: <9d3ec8300801310157r77b86fc0k80f40b1df36091c2@mail.gmail.com> <0640C30E-07B5-4885-AC38-671755BB79AA@erratique.ch> <47A1D68B.70700@fmf.uni-lj.si> X-Mailer: Apple Mail (2.915) Sender: =?ISO-8859-1?Q?Daniel=20B=FCnzli?= X-Miltered: at concorde with ID 47A229AF.000 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; bunzli:01 buenzli:01 andrej:01 recursive:01 runtime:01 stdin:01 stdin:01 jot:98 jot:98 rec:01 caml-list:01 functions:01 functions:01 exceptions:01 tail:01 Le 31 janv. 08 =E0 15:09, Andrej Bauer a =E9crit : > I have become to prefer option types as return values (as opposed to =20= > exceptions), but I admit it can be annoying to always consider both =20= > possibilities, especially if you know that "None" won't happen. Maybe it is a point of view, you are fed up of considering both =20 possibilites while I'm personally fed up of writing match try Some (f x) with e -> None with | None -> .. | Some v -> ... Because I need tail recursive functions. > If the library only provides "find" that returns an option type, the =20= > above solution gets around constant checking. But how much runtime =20 > overhead does it cause? Has anyone measured that? No idea. Unscientific benchmark at the end of the email. > What is wrong with having two functions? You have to choose. You don't have exceptionless error mangement =20 anymore which is the point of the proposal. As the module developer I =20= don't want to write two functions to do the same thing albeit in a =20 slight different way one of which strikes me as the being the wrong way. Best, Daniel osx 10.5.1 1ghz G4 512 ram > cat in.ml let () =3D let f =3D ref [] in try while (true) do f :=3D (input_line stdin) :: !f done with End_of_file -> ignore (!f) > cat inb.ml let () =3D let rec next acc =3D match try Some (input_line stdin) with End_of_file -> None with | None -> acc | Some l -> next (l :: acc) in ignore (next []) > ocamlbuild in.native inb.native Finished, 8 targets (0 cached) in 00:00:01. > time jot 1000000 | ./in.native real 0m4.814s user 0m4.371s sys 0m0.218s > time jot 1000000 | ./inb.native real 0m4.790s user 0m4.355s sys 0m0.217s=