<?xml version="1.0" encoding="ISO-8859-1"?>

<!DOCTYPE message PUBLIC
  "-//MLarc//DTD MLarc output files//EN"
  "../../mlarc.dtd"[
  <!ATTLIST message
    listname CDATA #REQUIRED
    title CDATA #REQUIRED
  >
]>

  <?xml-stylesheet href="../../mlarc.xsl" type="text/xsl"?>


<message 
  url="2003/07/012000871048c09c09b73acb0a767ec8"
  from="Jacques Garrigue &lt;garrigue@k...&gt;"
  author="Jacques Garrigue"
  date="2003-07-29T03:18:01"
  subject="Re: [Caml-list] assert caught by try with _"
  prev="2003/07/da955a051fbb26778695027528f86f7b"
  next="2003/07/81a0bd462ef07ae6386a9582e266680a"
  prev-in-thread="2003/07/da955a051fbb26778695027528f86f7b"
  next-in-thread="2003/07/421e11339985a294563f9b4fc0d5a34d"
  prev-thread="2003/07/976c83213750a167f0a635b7687ffe81"
  next-thread="2003/07/ba9f7a43c963a0693df6ce5d6c7736d4"
  root="../../"
  period="month"
  listname="caml-list"
  title="Archives of the Caml mailing list">

<thread subject="[Caml-list] assert caught by try with _">
<msg 
  url="2003/07/8d067f3472c9db2843900ad04bc1ddfd"
  from="Chris Hecker &lt;checker@d...&gt;"
  author="Chris Hecker"
  date="2003-07-28T18:43:41"
  subject="[Caml-list] assert caught by try with _">
<msg 
  url="2003/07/1b6ecd32d8cb08e0e226160a88d2418f"
  from="Nicolas Cannasse &lt;warplayer@f...&gt;"
  author="Nicolas Cannasse"
  date="2003-07-28T19:08:22"
  subject="Re: [Caml-list] assert caught by try with _">
<msg 
  url="2003/07/da955a051fbb26778695027528f86f7b"
  from="Chris Hecker &lt;checker@d...&gt;"
  author="Chris Hecker"
  date="2003-07-29T02:37:13"
  subject="Re: [Caml-list] assert caught by try with _">
<msg 
  url="2003/07/012000871048c09c09b73acb0a767ec8"
  from="Jacques Garrigue &lt;garrigue@k...&gt;"
  author="Jacques Garrigue"
  date="2003-07-29T03:18:01"
  subject="Re: [Caml-list] assert caught by try with _">
<msg 
  url="2003/07/421e11339985a294563f9b4fc0d5a34d"
  from="Chris Hecker &lt;checker@d...&gt;"
  author="Chris Hecker"
  date="2003-07-29T21:01:52"
  subject="Re: [Caml-list] assert caught by try with _">
<msg 
  url="2003/08/cc45ea5e2dc634955ab812e1d6fdacd7"
  from="Michal Moskal &lt;malekith@p...&gt;"
  author="Michal Moskal"
  date="2003-08-06T12:21:08"
  subject="Re: [Caml-list] assert caught by try with _">
<msg 
  url="2003/08/4aebd5f287a4e3d4cc44215ead37efd7"
  from="William Lovas &lt;wlovas@s...&gt;"
  author="William Lovas"
  date="2003-08-06T14:50:26"
  subject="Re: [Caml-list] assert caught by try with _">
<msg 
  url="2003/08/89bd326adba5da59a781ac6d3ad19564"
  from="Michal Moskal &lt;malekith@p...&gt;"
  author="Michal Moskal"
  date="2003-08-06T17:45:16"
  subject="Re: [Caml-list] assert caught by try with _">
</msg>
</msg>
</msg>
<msg 
  url="2003/07/af414b82397383bcb6da895d2858c783"
  from="Yaron M. Minsky &lt;yminsky@c...&gt;"
  author="Yaron M. Minsky"
  date="2003-07-30T10:22:20"
  subject="Re: [Caml-list] assert caught by try with _">
<msg 
  url="2003/07/40d54eae7f4ed6f16eb41e07c5c59e83"
  from="james woodyatt &lt;jhw@w...&gt;"
  author="james woodyatt"
  date="2003-07-30T15:47:38"
  subject="Re: [Caml-list] assert caught by try with _">
</msg>
</msg>
</msg>
</msg>
</msg>
</msg>
<msg 
  url="2003/07/b7392a72f9fe176635fedc6a184d67e1"
  from="Jason Hickey &lt;jyh@c...&gt;"
  author="Jason Hickey"
  date="2003-07-30T05:45:03"
  subject="[Caml-list] unwind-protect">
<msg 
  url="2003/07/5ff669a9d2be35ec585b536e2e0fc7ca"
  from="Yaron M. Minsky &lt;yminsky@c...&gt;"
  author="Yaron M. Minsky"
  date="2003-07-30T10:30:23"
  subject="Re: [Caml-list] unwind-protect">
<msg 
  url="2003/07/85b8e032e5a714fc6c464715b482bb2c"
  from="Didier Remy &lt;Didier.Remy@i...&gt;"
  author="Didier Remy"
  date="2003-07-30T17:25:46"
  subject="Re: [Caml-list] unwind-protect">
<msg 
  url="2003/07/0ee85c5c688c958d4d9c57749ea69cb2"
  from="Jacques Garrigue &lt;garrigue@k...&gt;"
  author="Jacques Garrigue"
  date="2003-07-31T00:47:09"
  subject="Re: [Caml-list] unwind-protect">
</msg>
</msg>
</msg>
<msg 
  url="2003/07/bb20974642b0a6c34c428a093f2086a5"
  from="William Lovas &lt;wlovas@s...&gt;"
  author="William Lovas"
  date="2003-07-30T14:44:21"
  subject="Re: [Caml-list] unwind-protect">
</msg>
</msg>
<msg 
  url="2003/07/7321c1d7a6a5de7042a617ca2c897309"
  from="Jason Hickey &lt;jyh@c...&gt;"
  author="Jason Hickey"
  date="2003-07-30T05:44:09"
  subject="Re: [Caml-list] assert caught by try with _">
</msg>
</msg>
</thread>

<contents>
From: Chris Hecker &lt;checker@d6.com&gt;

&gt; &gt;You could tell the same for stack overflow and some other kinds of
&gt; &gt;exceptions. OCaml uniformly treat failures as exceptions, and that's the
&gt; &gt;right thing to do. But catching exceptions with _ , without even printing
&gt; &gt;them, is not the "right thing" and is definitly huge pain and error prone.
&gt; 
&gt; I totally disagree about assert being the same as a stack overflow in 
&gt; nature, but more importantly, you're ignoring the lessons learned from C++ 
&gt; and Java on the exception specification front.  You just don't know what 
&gt; exceptions code you call in a real program will throw in general.  There 
&gt; are plenty of times when you want to try something at runtime and just bail 
&gt; if it doesn't work, and you don't care about the specifics of why it didn't 
&gt; work.  A single "with _" will mask any assertions living below it, which 
&gt; seems to me to be a bad thing since by definition an assert is a 
&gt; development debugging tool.  Assert should just blow up, like in C (at 
&gt; least as an option).  You shouldn't have to remember to put a "with" clause 
&gt; in for it.

But you might really want to catch assert failures!
For instance if you're building a debugging tool.
So the problem rather stems from the fact exn is a flat type. You have
no way to specify "categories" of exceptions, like you would do in
Java.
Also you could view the behaviour of [try ... with _ -&gt; ...] as
dangerous, and prefer a different behaviour. Unfortunately, _ is
expected to mean any exception, and it would be difficult to make it
mean something else.

Note that it's easy enough to define a class of exceptions as fatal:

let check_fatal = function
    Assert_failure _ | Stack_overflow | Match_failure _ as exn -&gt; raise exn
  | _ -&gt; ();;

Then you just have to write

  try ... with exn -&gt; check_fatal exn; ...

You can certainly use camlp4 to do this automatically.

Alternatively, one could argue that this is similar to the ctrl-break
problem: [Sys.catch_break] allows you to decide whether you want it to
be catchable or not. Unfortunately this would imply some extra cost
for [raise].

    Jacques

-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners

</contents>

</message>

