caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: "Yaron Minsky" <yminsky@cs.cornell.edu>
To: "Xavier Leroy" <Xavier.Leroy@inria.fr>
Cc: "Michaël Le Barbier" <michael.le_barbier@laposte.net>,
	caml-list@yquem.inria.fr
Subject: Re: [Caml-list] Preferred use of Invalid_argument and Failure
Date: Wed, 24 Oct 2007 07:05:08 -0400	[thread overview]
Message-ID: <891bd3390710240405l40ddee68l1d8876c7be98ff34@mail.gmail.com> (raw)
In-Reply-To: <471EFD20.5010303@inria.fr>

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

On 10/24/07, Xavier Leroy <Xavier.Leroy@inria.fr> wrote:
>
>
> I recommend the use of Invalid_argument to report "should never
> happen" conditions at the boundary between library functions and user
> code.  On the other hand, the "Failure" exception is a bit of a legacy
> from earlier designs (Caml Light and even the original LeLisp-based
> Caml), and often is not the best way to report "normal error"
> conditions: instead, you could consider defining your own exceptions
> as Alain suggested, or even have your functions return "option" types
> instead of raising exceptions.


Where I work, we have come to dearly love the practice of returning
polymorphic variants with explicit  variants for various "normal" error
cases.  This is pretty lightweight, and is also very clear and explicit,
both when looking at the function signature and at the call point.

y

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

  reply	other threads:[~2007-10-24 11:05 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-10-24  6:45 Michaël Le Barbier
2007-10-24  7:06 ` [Caml-list] " Alain Frisch
2007-10-24  8:06 ` Xavier Leroy
2007-10-24 11:05   ` Yaron Minsky [this message]
2007-10-24 11:30     ` Joel Reymont
2007-10-24 13:15       ` Yaron Minsky
2007-10-24 13:22         ` Daniel Bünzli
2007-10-24 14:45           ` Jon Harrop
2007-10-24 15:10           ` Richard Jones
2007-10-24 14:44         ` Jon Harrop
2007-10-25  7:07   ` Michaël Le Barbier

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=891bd3390710240405l40ddee68l1d8876c7be98ff34@mail.gmail.com \
    --to=yminsky@cs.cornell.edu \
    --cc=Xavier.Leroy@inria.fr \
    --cc=caml-list@yquem.inria.fr \
    --cc=michael.le_barbier@laposte.net \
    /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).