caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Yaron Minsky <yminsky@janestreet.com>
To: Ben Millwood <bmillwood@janestreet.com>
Cc: Goswin von Brederlow <goswin-v-b@web.de>,
	caml users <caml-list@inria.fr>
Subject: Re: [Caml-list] Uncaught exceptions in function type.
Date: Tue, 27 May 2014 07:24:32 -0400	[thread overview]
Message-ID: <CACLX4jRdMSAJ300Aiiux1DdGL3DFxyO=Og1GvbHAK+x9YDn2jw@mail.gmail.com> (raw)
In-Reply-To: <CA+MHO50hNag+g0gA=7xPzCLgyWFD46UZf2yKNjH4tZ-sjo11Ew@mail.gmail.com>

You shouldn't take Ben's comments to indicate that we don't ever throw
exceptions.  We have lots of functions whose names are explicit about
the fact that they throw exceptions, like Map.find_exn or
List.last_exn.  They have legitimate uses, for example, in contexts
where you've checked that the precondition for that function to not
throw an exception, and so it would simply be a bug if it were thrown.
 In those cases, it is indeed hard to change the specific exception
that is thrown without potentially breaking external code that depends
on it.

That's why in new modules, are usual behavior is to not expose the
concrete exceptions we declare in the mli of our modules, on the
theory that we don't want users of the module to depend on the
identity of an exception.

y

On Tue, May 27, 2014 at 6:36 AM, Ben Millwood <bmillwood@janestreet.com> wrote:
> On 27 May 2014 11:05, Goswin von Brederlow <goswin-v-b@web.de> wrote:
>>
>> On Tue, May 27, 2014 at 09:42:35AM +0100, Ben Millwood wrote:
>> > This is essentially why we still have a few Not_found exceptions in
>> > Core,
>> > because it's really pretty hard to know where they might be relied upon,
>> > so
>> > it's easier to leave them in than purge them and risk silent breakage.
>>
>> HUH?
>>
>> Say you have a function
>>
>> val f : ('a, 'b) t -> 'a -> 'b   (raise [Not_found])
>>
>> then eliminating Not_found that function would become
>>
>> val f : ('a, 'b) t -> 'a -> 'b option
>>
>> That should fail to compile if the return type is used or a signature
>> exists. Where do you think a change would go unnoticed?
>>
>> MfG
>>         Goswin
>
>
> I really mean where we'd like to change Not_found to a more informative or
> appropriate exception. Sorry, I forgot about one case where we are
> completely fine with using exceptions: in (usually short-lived) programs
> where the correct behaviour on error is always to explode apologetically
> right there and then. The choice of exception is still relevant because it
> affects the quality of the backtrace and message.

  reply	other threads:[~2014-05-27 11:24 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 [this message]
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
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='CACLX4jRdMSAJ300Aiiux1DdGL3DFxyO=Og1GvbHAK+x9YDn2jw@mail.gmail.com' \
    --to=yminsky@janestreet.com \
    --cc=bmillwood@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).