caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: David House <dhouse@janestreet.com>
To: Goswin von Brederlow <goswin-v-b@web.de>
Cc: OCaml Mailing List <caml-list@inria.fr>
Subject: Re: [Caml-list] Uncaught exceptions in function type.
Date: Tue, 27 May 2014 09:56:43 +0100	[thread overview]
Message-ID: <CAK=fH+ja+NG2-Tu-MkCG+hsXkN14nh5AYD=oot-fAo2V6eg1CA@mail.gmail.com> (raw)
In-Reply-To: <20140527084954.GA15848@frosties>

[-- Attachment #1: Type: text/plain, Size: 1745 bytes --]

On 27 May 2014 09:49, Goswin von Brederlow <goswin-v-b@web.de> 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
>

[-- Attachment #2: Type: text/html, Size: 3134 bytes --]

  reply	other threads:[~2014-05-27  8:56 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-05-26 14:23 Philippe Veber
2014-05-26 14:56 ` Romain Bardou
2014-05-26 15:13   ` Ben Millwood
2014-05-26 16:02     ` Philippe Veber
2014-05-26 16:34       ` Daniel Bünzli
2014-05-27  6:52         ` Philippe Veber
2014-05-27  8:42           ` Ben Millwood
2014-05-27 10:05             ` Goswin von Brederlow
2014-05-27 10:36               ` Ben Millwood
2014-05-27 11:24                 ` Yaron Minsky
2014-05-27 21:42             ` Daniel Bünzli
2014-05-27 21:16           ` Daniel Bünzli
2014-06-02  8:38             ` Goswin von Brederlow
2014-05-27  8:49         ` Goswin von Brederlow
2014-05-27  8:56           ` David House [this message]
2014-05-27 21:39           ` Daniel Bünzli
2014-06-02  8:31             ` Goswin von Brederlow
2014-05-27  9:25         ` Nicolas Boulay
2014-05-27 21:51           ` Daniel Bünzli
2014-05-30 18:03         ` Florian Weimer
2014-05-31 11:26           ` Daniel Bünzli
2014-06-02  8:43             ` Goswin von Brederlow
2014-05-26 15:25   ` Philippe Veber
2014-05-27  9:28     ` Goswin von Brederlow
2014-05-27  9:38       ` Romain Bardou
2014-05-26 15:33 ` Thomas Blanc
2014-05-26 16:04   ` Philippe Veber
2014-05-26 15:33 ` Gabriel Scherer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAK=fH+ja+NG2-Tu-MkCG+hsXkN14nh5AYD=oot-fAo2V6eg1CA@mail.gmail.com' \
    --to=dhouse@janestreet.com \
    --cc=caml-list@inria.fr \
    --cc=goswin-v-b@web.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).