Version française
Home     About     Download     Resources     Contact us    
Browse thread
[Caml-list] assert caught by try with _
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Jason Hickey <jyh@c...>
Subject: Re: [Caml-list] assert caught by try with _
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