English version
Accueil     À propos     Téléchargement     Ressources     Contactez-nous    

Ce site est rarement mis à jour. Pour les informations les plus récentes, rendez-vous sur le nouveau site OCaml à l'adresse ocaml.org.

Browse thread
[Caml-list] Exceptions considered harmful
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2004-07-04 (20:24)
From: Michael Hicks <mwh@c...>
Subject: Re: [Caml-list] Exceptions considered harmful
> try
>   x <- foo ()
> in
>   bar ()
> unless
>   E1 -> handle1 ()
>   E2 -> handle2 ()

The key part to this approach is that bar() is not covered by the 
exception handler.   This allows the caller to communicate the 
successfully created value into bar() through x.  In a traditional 
setting, you'd have something like

let x := NONE;
try
   x := SOME foo();
with E1 -> ....

if !x <> NONE then bar !x
else ??

Mike

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