caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Jason Hickey <jyh@cs.caltech.edu>
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] assert caught by try with _
Date: Tue, 29 Jul 2003 22:44:03 -0700	[thread overview]
Message-ID: <3F275B23.6050100@cs.caltech.edu> (raw)
In-Reply-To: <4.3.2.7.2.20030728112622.02f3fef8@localhost>

Chris Hecker wrote:
> Is the the "right thing" for assert to be caught by a try ... with _ -> 
> ... block?

I don't know.  It seems reasonable to have exceptional conditions caught 
by the exception handler...

However, it may be reasonable to ask for more than one exception 
type--it seems like poor software engineering to statically list *all* 
the possible reasonable exceptions in a try/with block, except for 
Assert_failure.  This idea will fail as new exceptions are added.

To help avoid this problem, in our work we generally declare a type of 
application errors (not the exact syntax but close enough):

    type application_error =
       NoClue
     | BadIdea of string
     | IWouldIfICouldButICantSoIWont
     | ...

    exception ApplicationError of application_error

All raises are of the form (raise (ApplicationError ...)), and the 
"default" exception handler is (try ... with ApplicationError _ -> ...). 
  This idea works ok, but is not scalable.

Jason

-- 
Jason Hickey                  http://www.cs.caltech.edu/~jyh
Caltech Computer Science      Tel: 626-395-6568 FAX: 626-792-4257

-------------------
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


  parent reply	other threads:[~2003-07-30  5:44 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-07-28 18:34 Chris Hecker
2003-07-28 19:08 ` Nicolas Cannasse
2003-07-29  2:37   ` Chris Hecker
2003-07-29  3:17     ` Jacques Garrigue
2003-07-29 21:01       ` Chris Hecker
2003-07-30 10:22         ` Yaron M. Minsky
2003-07-30 15:47           ` james woodyatt
2003-08-06 12:19         ` Michal Moskal
2003-08-06 14:50           ` William Lovas
2003-08-06 17:44             ` Michal Moskal
2003-07-30  5:44 ` Jason Hickey [this message]
2003-07-30  5:44 ` [Caml-list] unwind-protect Jason Hickey
2003-07-30 10:30   ` Yaron M. Minsky
2003-07-30 17:29     ` Didier Remy
2003-07-31  0:47       ` Jacques Garrigue
2003-07-30 14:44   ` William Lovas
2003-07-29 22:55 [Caml-list] assert caught by try with _ Martin Berger

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=3F275B23.6050100@cs.caltech.edu \
    --to=jyh@cs.caltech.edu \
    --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;
as well as URLs for NNTP newsgroup(s).