caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Jean-vincent.Loddo@lipn.univ-paris13.fr
To: <caml-list@inria.fr>
Subject: [Caml-list] Lazyness and exceptions
Date: Thu, 22 Nov 2012 11:29:08 +0100	[thread overview]
Message-ID: <b3cd867690b0f42d9c5a3bb1b22f7b2d@lipn.univ-paris13.fr> (raw)

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


             reply	other threads:[~2012-11-22 10:29 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-11-22 10:29 Jean-vincent.Loddo [this message]
2012-11-22 10:33 ` Török Edwin
2012-11-22 10:37   ` David House
2012-11-22 10:57     ` Jean-vincent.Loddo

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=b3cd867690b0f42d9c5a3bb1b22f7b2d@lipn.univ-paris13.fr \
    --to=jean-vincent.loddo@lipn.univ-paris13.fr \
    --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).