From: "Chris King" <colanderman@gmail.com>
To: "Bruno De Fraine" <Bruno.De.Fraine@vub.ac.be>
Cc: caml-list@inria.fr
Subject: Re: Ocaml checked exceptions
Date: Fri, 22 Dec 2006 23:23:43 -0500 [thread overview]
Message-ID: <875c7e070612222023j425f7a47yb83da6725196afc7@mail.gmail.com> (raw)
In-Reply-To: <C841DA73-83D4-4CDD-BF4A-EA803C6D6A08@vub.ac.be>
On 12/18/06, Bruno De Fraine <Bruno.De.Fraine@vub.ac.be> wrote:
> I think support in the type system for exceptions would look a lot
> like that for polymorphic variants. You can do some of the things you
> suggest with them, but there are some important shortcomings (other
> than the obvious issue that an exception aborts the normal control
> flow and moves up the stack until it is handled).
Agreed, I wonder if a proof-of-concept syntax extension could be
written to take advantage of this similarity? (Of course its
performance would be abysmal! but it would be a good way to try such a
system in a larger project.)
> > val List.iter: ('a -> unit raises 'b) -> 'a list -> unit raises 'b
>
> val iter : ('a -> ([> `Val of unit ] as 'b)) -> 'a list -> 'b = <fun>
>
> This is a bit different from how you describe the type, but in
> principle I can agree: "iter will have the same return type as the
> argument function; this should include a normal unit value".
Yes, this type seems to fit well.
> > val catch_failures: ('a -> 'b raises [Failure of string | 'c]) -> 'a
> > -> 'b raises 'c
>
> val catch_failures :
> ('a -> ([> `Failure of string | `Val of 'c ] as 'b)) -> 'a -> 'c -
> > 'b =
> <fun>
>
> It is problematic that the final return type will be the same as that
> from the argument. I.e. the exception that we catch is not removed:
OcamlExc (http://caml.inria.fr/pub/old_caml_site/ocamlexc/ocamlexc.htm)
seems to make some headway into this problem by doing flow analysis...
whether it can handle this specific case I'm not sure but I wouldn't
be surprised.
I also know of no way to express this using variants. Although we
could say something like
val catch_failures : ('a -> ([> `Failure of string | `Val of 'c |
everything_else ] as 'b)) -> 'a -> 'c -> everything_else
and replace the default match case with a case matching [>
everything_else], there's currently no way (that I know of) to create
the "everything_else" type abbreviation, short of enumerating all
known exceptions manually.
- Chris
next prev parent reply other threads:[~2006-12-23 4:23 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-12-10 1:42 Today's inflamatory opinion: exceptions are bad Brian Hurt
2006-12-10 2:40 ` [Caml-list] " skaller
2006-12-10 2:51 ` Martin Jambon
2006-12-10 3:35 ` Chris King
2006-12-10 6:32 ` Jon Harrop
2006-12-10 19:07 ` brogoff
2006-12-10 18:04 ` Richard Jones
2006-12-10 23:27 ` Chris King
2006-12-11 15:55 ` Richard Jones
2006-12-15 11:13 ` Frédéric Gava
2006-12-11 17:28 ` Mike Lin
2006-12-11 20:09 ` Richard Jones
2006-12-11 23:38 ` Olivier Andrieu
[not found] ` <C841DA73-83D4-4CDD-BF4A-EA803C6D6A08@vub.ac.be>
2006-12-23 4:23 ` Chris King [this message]
2006-12-10 6:30 ` malc
2006-12-10 6:36 ` malc
2006-12-10 6:56 ` Jon Harrop
2006-12-10 9:51 ` Andreas Rossberg
2006-12-10 11:00 ` Tom
2006-12-10 11:25 ` Andreas Rossberg
2006-12-10 13:27 ` Jean-Christophe Filliatre
2006-12-10 19:15 ` Haoyang Wang
2006-12-10 21:43 ` Jean-Christophe Filliatre
2006-12-11 13:10 ` Diego Olivier FERNANDEZ PONS
2006-12-10 18:31 ` Serge Aleynikov
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=875c7e070612222023j425f7a47yb83da6725196afc7@mail.gmail.com \
--to=colanderman@gmail.com \
--cc=Bruno.De.Fraine@vub.ac.be \
--cc=caml-list@inria.fr \
/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