caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] Lazyness and exceptions
@ 2012-11-22 10:29 Jean-vincent.Loddo
  2012-11-22 10:33 ` Török Edwin
  0 siblings, 1 reply; 4+ messages in thread
From: Jean-vincent.Loddo @ 2012-11-22 10:29 UTC (permalink / raw)
  To: caml-list

Hello,

I have observed a strange behaviour of lazy values when an exception is 
raised. Here a minimal code that reproduces the behaviour:

# let action =
     let thunk () =
       Printf.printf "aaa\n";
       failwith "bbb"
     in
     lazy (thunk ());;

val action : unit lazy_t = <lazy>

# Lazy.force action ;;
aaa
Exception: Failure "bbb".

# Lazy.force action ;;
Exception: Failure "bbb".

The lazy value seems to be (correctly) not re-evaluated but the 
exception is (strangely) raised again. Why does this happen?
Jean-Vincent Loddo


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2012-11-22 10:57 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-11-22 10:29 [Caml-list] Lazyness and exceptions Jean-vincent.Loddo
2012-11-22 10:33 ` Török Edwin
2012-11-22 10:37   ` David House
2012-11-22 10:57     ` Jean-vincent.Loddo

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