From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@sympa.inria.fr Delivered-To: caml-list@sympa.inria.fr Received: from mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by sympa.inria.fr (Postfix) with ESMTPS id 905B87EE5B for ; Tue, 27 May 2014 10:56:47 +0200 (CEST) Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of dhouse@janestreet.com) identity=pra; client-ip=38.105.200.112; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="dhouse@janestreet.com"; x-sender="dhouse@janestreet.com"; x-conformance=sidf_compatible Received-SPF: Pass (mail3-smtp-sop.national.inria.fr: domain of dhouse@janestreet.com designates 38.105.200.112 as permitted sender) identity=mailfrom; client-ip=38.105.200.112; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="dhouse@janestreet.com"; x-sender="dhouse@janestreet.com"; x-conformance=sidf_compatible; x-record-type="v=spf1" Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of postmaster@mxout1.mail.janestreet.com) identity=helo; client-ip=38.105.200.112; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="dhouse@janestreet.com"; x-sender="postmaster@mxout1.mail.janestreet.com"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AroBAHpShFMmachwnGdsb2JhbABZg1lYgmqpU4EHi1SIfAGBBwgWDgEBAQEBBhYJPIIlAQEBAwESER0BASwLAQQLCQILGh0CAiISAQUBChIGExIJB4gMAwkIAwIIkxmQD2qKMHeEfwEFmUUDH4YFEQaJM4UbBAeCdYFLhGIFlRCBPY95GCmEaQ X-IPAS-Result: AroBAHpShFMmachwnGdsb2JhbABZg1lYgmqpU4EHi1SIfAGBBwgWDgEBAQEBBhYJPIIlAQEBAwESER0BASwLAQQLCQILGh0CAiISAQUBChIGExIJB4gMAwkIAwIIkxmQD2qKMHeEfwEFmUUDH4YFEQaJM4UbBAeCdYFLhGIFlRCBPY95GCmEaQ X-IronPort-AV: E=Sophos;i="4.98,917,1392159600"; d="scan'208";a="64301905" Received: from mxout1.mail.janestreet.com ([38.105.200.112]) by mail3-smtp-sop.national.inria.fr with ESMTP/TLS/DHE-RSA-AES256-SHA; 27 May 2014 10:56:46 +0200 Received: from tot-smtp.delacy.com ([172.27.22.15] helo=tot-smtp) by mxout1.mail.janestreet.com with esmtps (TLSv1.2:DHE-RSA-AES256-GCM-SHA384:256) (Exim 4.82) (envelope-from ) id 1WpDBb-0002eX-Ks for caml-list@inria.fr; Tue, 27 May 2014 04:56:43 -0400 Received: from tot-dmz-mxgoog1.delacy.com ([172.27.224.14] helo=mxgoog2.janestreet.com) by tot-smtp with esmtps (TLSv1:AES256-SHA:256) (Exim 4.72) (envelope-from ) id 1WpDBb-00011W-Hs for caml-list@inria.fr; Tue, 27 May 2014 04:56:43 -0400 Received: from mail-qg0-f42.google.com ([209.85.192.42]) by mxgoog2.janestreet.com with esmtp (Exim 4.76) (envelope-from ) id 1WpDBb-0000IZ-G9 for caml-list@inria.fr; Tue, 27 May 2014 04:56:43 -0400 Received: by mail-qg0-f42.google.com with SMTP id q107so13495449qgd.15 for ; Tue, 27 May 2014 01:56:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=janestreet.com; s=google; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=aZ4MSrIdRpaq8luGe6i0mC7ln0zROZ4J4BiVo63Imx4=; b=A4xidZLTetcCfwUSx7n3sdon4pdE90i2AhE5RZ6HQWdeyD3uis74a4oqdjNDsLZG6X pXFec4Snnj7epKGILps19bsiqhPLBfaNhrklm6hubGrDt0tafHBQWCDnhYyy8NxrRE0N uvlgh66L4Wt7GTCS1xn+QC7gqayLNopQseIL8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc:content-type; bh=aZ4MSrIdRpaq8luGe6i0mC7ln0zROZ4J4BiVo63Imx4=; b=FVg/NgWZ7dKK39xnNBwXbKUXfGbbNqwSkTyaggahy3zQMpkorUpuwWFC22ZztX2t0g 5R2FBpJFomdynS4HZx1scOYZShDef1KlMYlq6UukUcL5Iw9N73Z1vQbPNGw6JedTY/P5 fFcn5vwF6p6Wx+YpR9/ecfjscYMxszzwh4m+nuZHVI4cYFOto2LZibZ82BoQ7LppNw7W tF80xEH5mWbmBOonzehaHJBbPtoqmub2m6mxxCmlUIRo0COJd5Ytwjil3qOS/VZeCQUo 6/Hxdon/eztu7e/N5iLyQDkItb4pMUDy1S2tkak494X722YzMp7mymoEf19+0+pROmWB BjjQ== X-Gm-Message-State: ALoCoQnP6I78WVTDK5dK6soQfKVoZ8Jx2WG8M6Y93ZNTwioOHAC11Ar/wJvKFs0ZYVT6vUueuDfT/xsjr36OpSKCwSTKcAgLOOCy45DgyEn9mVB46eEMK1uiFBwb1z5Dlc8OokxNegLJ X-Received: by 10.224.103.129 with SMTP id k1mr40704714qao.62.1401181003348; Tue, 27 May 2014 01:56:43 -0700 (PDT) MIME-Version: 1.0 X-Received: by 10.224.103.129 with SMTP id k1mr40704710qao.62.1401181003294; Tue, 27 May 2014 01:56:43 -0700 (PDT) Received: by 10.140.30.98 with HTTP; Tue, 27 May 2014 01:56:43 -0700 (PDT) In-Reply-To: <20140527084954.GA15848@frosties> References: <53835610.9050609@inria.fr> <53B801AD6F5B4BFBA0DA2A69D8775497@erratique.ch> <20140527084954.GA15848@frosties> Date: Tue, 27 May 2014 09:56:43 +0100 Message-ID: From: David House To: Goswin von Brederlow Cc: OCaml Mailing List Content-Type: multipart/alternative; boundary=047d7b66f74bf7b71804fa5ddf5a Subject: Re: [Caml-list] Uncaught exceptions in function type. --047d7b66f74bf7b71804fa5ddf5a Content-Type: text/plain; charset=UTF-8 On 27 May 2014 09:49, Goswin von Brederlow wrote: > > * Non-exceptional errors, errors that the programmer will have to > > handle (e.g. failing to connect a socket), for that do not use a > > custom exception but use variants or options types. > > That is a matter of taste and with recursions in the mix exceptions > can be a great way to abort the recursion while keeping the code flow > simple. They also allow you to use things like List.fold_left and > abort early. > See https://blogs.janestreet.com/core-gems-many-happy-returns/ for how we solve this problem in core. The interface is very natural. It uses exceptions under the hood, although that is not exposed. However, I think this is entirely separate from the rest of the discussion. Here we are merely using exceptions for their control flow properties -- there is no error condition. > Variants or option types are not always the best solution. > That's certainly true, although I would argue that exceptions are certainly overused. We use them quite a bit in core and in the rest of JS's codebase -- but only for truly "exceptional" circumstances. > > In general if you write libraries it???s better to err on the side > > of exceptionless design: never use exceptions beyond Invalid_argument > > (and especially never use Not_found or Failure). Leave exception > > definition/usage at the discretion of the user (if he wishes to shoot > > himself in the foot). > > > > Best, > > > > Daniel > > MfG > Goswin > > -- > Caml-list mailing list. Subscription management and archives: > https://sympa.inria.fr/sympa/arc/caml-list > Beginner's list: http://groups.yahoo.com/group/ocaml_beginners > Bug reports: http://caml.inria.fr/bin/caml-bugs > --047d7b66f74bf7b71804fa5ddf5a Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
On 2= 7 May 2014 09:49, Goswin von Brederlow <goswin-v-b@web.de> w= rote:
> * Non-exceptional errors, errors that= the programmer will have to
> handle (e.g. failing to connect a socket), for that do not use a
> custom exception but use variants or options types.

That is a matter of taste and with recursions in the mix exceptions can be a great way to abort the recursion while keeping the code flow
simple. They also allow you to use things like List.fold_left and
abort early.

See=C2=A0https://blogs.janestr= eet.com/core-gems-many-happy-returns/ for how we solve this problem in = core. The interface is very natural. It uses exceptions under the hood, alt= hough that is not exposed.

However, I think this is entirely separate from the res= t of the discussion. Here we are merely using exceptions for their control = flow properties -- there is no error condition.
=C2=A0
Variants or option types are not always the best solution.
=

That's certainly true, although I would argue that = exceptions are certainly overused. We use them quite a bit in core and in t= he rest of JS's codebase -- but only for truly "exceptional" = circumstances.
=C2=A0
> In general if you write libraries it???s better to err on the side
> of exceptionless design: never use exceptions beyond I= nvalid_argument
> (and especially never use Not_found or Failure). Leave exception
> definition/usage at the discretion of the user (if he wishes to shoot<= br> > himself in the foot).
>
> Best,
>
> Daniel

MfG
=C2=A0 =C2=A0 =C2=A0 =C2=A0 Goswin=

--
Caml-list mailing list. =C2=A0Subscription management and archives:
ht= tps://sympa.inria.fr/sympa/arc/caml-list
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
Bug reports: http://caml.inria.fr/bin/caml-bugs

--047d7b66f74bf7b71804fa5ddf5a--