From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 CDDADBC57 for ; Wed, 26 May 2010 23:10:02 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AqAGAMsq/UtKfVKsXmdsb2JhbACIRYkdMIwDCAsgEhAFH7FaggGFQS6ITwEBAwWFDgQ X-IronPort-AV: E=Sophos;i="4.53,306,1272837600"; d="scan'208";a="60089826" Received: from mail-wy0-f172.google.com ([74.125.82.172]) by mail1-smtp-roc.national.inria.fr with ESMTP; 26 May 2010 23:10:01 +0200 Received: by wye20 with SMTP id 20so60191wye.3 for ; Wed, 26 May 2010 14:10:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:received:in-reply-to :references:date:message-id:subject:from:to:cc:content-type; bh=ZanDgDxncT8fRBNfhJQU6S+CISSyzTGyGjI9wr+lbmg=; b=voXL9VkLN8QmU6XrnJMGsXQp0ceSPfO1HVhCI4L2kBD/G0hqoV29FIzxu2DQIgcUty eixBwdIWnuj+hqq1R9F5al0ORanXx6qllV2Q7ozpiU/WahTwW6Dy3emPAiDuy3qQow6j 2h7sqTvTPPJtcDvuAB39u8YK+LTfiLP80x8Ug= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; b=BlwKcYxo/5cCBOR0D6JplmIeFBX75ijO+QOjrJeTAm1u7JMfvh+ghMqU+GdgLd25iP kKGRIstmqVICRepyGdJaz2pxkHNysoPLbUPhNtoTr843Y3IJlX1thx/MYPZ1cv5TcsFO Kx2T6BsyUTARf1qmUoIbqlr3Q1uQmd/u63S8U= MIME-Version: 1.0 Received: by 10.216.163.204 with SMTP id a54mr113433wel.2.1274908201199; Wed, 26 May 2010 14:10:01 -0700 (PDT) Received: by 10.216.0.71 with HTTP; Wed, 26 May 2010 14:10:01 -0700 (PDT) In-Reply-To: <956439.81564.qm@web111506.mail.gq1.yahoo.com> References: <956439.81564.qm@web111506.mail.gq1.yahoo.com> Date: Wed, 26 May 2010 23:10:01 +0200 Message-ID: Subject: Re: [Caml-list] Static exception analysis or alternative to using exceptions From: Hans Ole Rafaelsen To: Dario Teixeira Cc: caml-list@yquem.inria.fr Content-Type: multipart/alternative; boundary=0016367f9f6e742a10048785b218 X-Spam: no; 0.00; rafaelsen:01 monads:01 ocaml:01 runtime:01 stdlib:01 syntax:01 monads:01 ocaml:01 runtime:01 stdlib:01 syntax:01 26,:98 26,:98 invoke:01 invoke:01 --0016367f9f6e742a10048785b218 Content-Type: text/plain; charset=ISO-8859-1 On Wed, May 26, 2010 at 7:30 PM, Dario Teixeira wrote: > Hi, > > > What experience does people have to using alternatives to exceptions, > > such as option types or exception monads? Does use of third part > > libraries that still throws exceptions make such approaches hard to use? > > Performance wise it seems to be comparable to catching exceptions or > > matching for options, so I guess the difference be might a question of > > programming style? > > Partly yes, though I would say that in Ocaml it is tempting to use > exceptions beyond what is reasonable, because they are so cheap and > convenient. As you noted, this can lead to trouble at runtime, which > is why some libraries discourage the "exceptional style", preferring > option types and forcing users to invoke functions suffixed by "_exc" > if they really want to use the exception-based version. > > Personally, I think the litmus test hinges on whether the supposedly > exceptional situation is truly worthy of the name. If it's a common > occurrence, perhaps one should reconsider the use of an "exception". > Without meaning to start an holy war, let me just add that even on > the Stdlib there are functions (such as Map.S.find) that raise an > exception but which should perhaps return an option type. > > Btw, you didn't mention it explicitly in your message, but I trust you > are familiar with "Catch me if you can"? [1] > I have just read about it, not tested it yet. Do you have any experience using this library, especially together with other libraries that also provides syntax extension? > > Best regards, > Dario Teixeira > > [1] > http://dutherenverseauborddelatable.wordpress.com/downloads/exception-monads-for-ocaml/ > > > > > Thanks, Hans Ole --0016367f9f6e742a10048785b218 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable

On Wed, May 26, 2010 at 7:30 PM, Dario T= eixeira <da= rioteixeira@yahoo.com> wrote:
Hi,

> What experience does people have to using alternatives to exceptions,<= br> > such as option types or exception monads? Does use of third part
> libraries that still throws exceptions make such approaches hard to us= e?
> Performance wise it seems to be comparable to catching exceptions or > matching for options, so I guess the difference be might a question of=
> programming style?

Partly yes, though I would say that in Ocaml it is tempting to use
exceptions beyond what is reasonable, because they are so cheap and
convenient. =A0As you noted, this can lead to trouble at runtime, which
is why some libraries discourage the "exceptional style", preferr= ing
option types and forcing users to invoke functions suffixed by "_exc&q= uot;
if they really want to use the exception-based version.

Personally, I think the litmus test hinges on whether the supposedly
exceptional situation is truly worthy of the name. =A0If it's a common<= br> occurrence, perhaps one should reconsider the use of an "exception&quo= t;.
Without meaning to start an holy war, let me just add that even on
the Stdlib there are functions (such as Map.S.find) that raise an
exception but which should perhaps return an option type.

Btw, you didn't mention it explicitly in your message, but I trust you<= br> are familiar with "Catch me if you can"? [1]
I have just read about it, not tested it yet. Do you have any experience u= sing this library, especially together with other libraries that also provi= des syntax extension?
=A0

Best regards,
Dario Teixeira

[1] http://dutherenverseaubordde= latable.wordpress.com/downloads/exception-monads-for-ocaml/




Thanks,

Hans Ole
--0016367f9f6e742a10048785b218--