caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: "blue storm" <bluestorm.dylc@gmail.com>
To: "David Teller" <David.Teller@univ-orleans.fr>
Cc: "Michael Ekstrand" <michael+ocaml@elehack.net>, caml-list@inria.fr
Subject: Re: [Caml-list] [OSR] Exceptionless error management
Date: Thu, 31 Jan 2008 21:05:10 +0100	[thread overview]
Message-ID: <527cf6bc0801311205n522c1c2ajfd46ea0fa773292@mail.gmail.com> (raw)
In-Reply-To: <1201807692.6565.14.camel@Blefuscu>

My two cents :

- It's easy to derive variant-defined functions from the
exception-using ones, with virtually no performance cost. Going the
other way is not as practical, and i assume it has a higher runtime
overhead
- We will need to document our functions in any case : the exception
name generally doesn't provide an accurate enough description of the
causes of the error (be it an exception, a polymorphic variant, ...)
- The added safety is good, but not (in my eyes) essential for every
use; we could use tools, eg. OcamlExc (
http://caml.inria.fr/pub/old_caml_site/ocamlexc/ocamlexc.htm ) to
check the safety as well
- In most situation, exceptions allow for a more natural and more
concise code than options/variants/monads, precisely because they can
break flow of control (eg. in a "for" loop), and because our libs are
not quite adapted to that kind of programming now (where is mapM ?)

I would favor the conservative solution : still provide the exception
handling by default, and allowing an additional option/variants
version.

On 1/31/08, David Teller <David.Teller@univ-orleans.fr> wrote:
> Differentiating functions sounds like a good idea.
>
> We may either:
> * add a suffix after function names whenever they may raise exceptions
> (suffix "_exn" sounds good to me)
> * add a suffix after function names whenever they are variants that
> don't raise exceptions (say, suffix "_maybe")
> * write two different (sub)modules with the same set of functions, one
> module being named Exception, the other one being named Option.
>
> What else ? We could presumably functorize modules upon the definition
> of a error-delivery mechanism, but that might be overkill.
>
> Say
> module type ErrorMechanism = sig
>   type 't;                (**The type of a failure.*)
>   type 'a can_fail;
>                           (**The type of a value that can either succeed
>                              and produce a result of type 'a or fail and
>                              produce an error of type t. *)
>   value fail    : t -> 'a can_fail ;
>                           (**Fail. Depending on the mechanism, this may
>                              either return some variant on option or
>                              throw an exception.*)
>
>   value succeed : 'a -> 'a can_fail ;
>                           (**Succeed.*)
> end;;
>
> We could also introduce an exception monad which would be an
> intermediate choice between using exceptions and using option types and
> such. I have a just written a prototype for this, I'll try and release
> it soon.
>
> Cheers,
>  David
>
> On Thu, 2008-01-31 at 08:16 -0600, Michael Ekstrand wrote:
> > While `get' and `search' are probably OK (I presume that `get' raises
> > an exception, and `search' returns an option type), we must be
> > careful.  If multiple functions is the standard, I would prefer that a
> > naming/variant system be recommended (such as get and get_exn).  If we
> > come up with clever names for our various functions, I fear the Java
> > Queue API syndrome (where you can get a value with any of 4 different
> > functions, and add with another 4, that mostly differ in how they
> > handle error and thread blocking conditions and the names have little
> > correlation to the differences).
> >
> > - Michael
>
> --
> David Teller
>  Security of Distributed Systems
>   http://www.univ-orleans.fr/lifo/Members/David.Teller
>  Angry researcher: French Universities need reforms, but the LRU act
> brings liquidations.
>
> _______________________________________________
> Caml-list mailing list. Subscription management:
> http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list
> Archives: http://caml.inria.fr
> Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
> Bug reports: http://caml.inria.fr/bin/caml-bugs
>


  parent reply	other threads:[~2008-01-31 20:05 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-01-31  8:55 Bünzli Daniel
2008-01-31  9:57 ` [Caml-list] " Till Varoquaux
2008-01-31 11:01   ` Bünzli Daniel
2008-01-31 14:09     ` Andrej Bauer
2008-01-31 14:16       ` Michael Ekstrand
2008-01-31 19:28         ` David Teller
2008-01-31 19:59           ` Michael Ekstrand
2008-01-31 20:05           ` blue storm [this message]
2008-01-31 20:03       ` Bünzli Daniel
2008-01-31 20:25         ` David Teller
2008-01-31 20:40           ` David Teller
2008-01-31 21:16           ` Bünzli Daniel
2008-01-31 21:31             ` David Teller
2008-01-31 21:35           ` Jon Harrop
2008-01-31 22:01           ` Christophe Raffalli
2008-02-01  7:27         ` Michaël Grünewald
2008-02-01  7:47           ` Bünzli Daniel
2008-02-01 10:50             ` Till Varoquaux
2008-02-01 11:31               ` Bünzli Daniel
2008-02-01 15:59                 ` Vincent Hanquez
2008-02-01 18:37                   ` Bünzli Daniel
2008-02-01 19:43                     ` Vincent Hanquez
2008-02-01 16:04                 ` David Allsopp
2008-02-01  8:31 ` David Teller
2008-02-01 12:19   ` Yaron Minsky
2008-02-05 10:00 ` David Teller
2008-02-05 10:12   ` Vincent Hanquez
2008-02-05 10:26     ` Bünzli Daniel
2008-02-05 11:06       ` Vincent Hanquez
2008-02-05 13:46         ` Jon Harrop
2008-02-05 11:36       ` Frédéric van der Plancke
2008-02-06  8:45       ` Michaël Grünewald
2008-02-08 13:09         ` Bünzli Daniel
2008-02-05 14:12     ` David Teller
2008-02-11  8:12 ` David Teller
2008-02-11  9:09   ` Bünzli Daniel

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=527cf6bc0801311205n522c1c2ajfd46ea0fa773292@mail.gmail.com \
    --to=bluestorm.dylc@gmail.com \
    --cc=David.Teller@univ-orleans.fr \
    --cc=caml-list@inria.fr \
    --cc=michael+ocaml@elehack.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).