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: Re: [Caml-list] Lazyness and exceptions
Date: Thu, 22 Nov 2012 11:57:53 +0100	[thread overview]
Message-ID: <cd07e4672b830d6fc91f5f691b057ab8@lipn.univ-paris13.fr> (raw)
In-Reply-To: <CAK=fH+jJF4FoW1zrFBem6cLhkmdA8FpU0ofmFdrAJTkECFU1dw@mail.gmail.com>

Ok, I understand now why. In the case of my example this choice could 
be discussed because of the nature of the output (unit), because it's 
not clear if the exception belongs to the output domain of the function 
or not (it's a semantics question). However, in the general case we 
cannot provide a reasonable output without re-evaluating the expression.
Thanks.

On Thu, 22 Nov 2012 10:37:23 +0000, David House wrote:
> In other words: what alternative semantics would you actually want?
>
> On Thu, Nov 22, 2012 at 10:33 AM, Török Edwin
> <edwin+ml-ocaml@etorok.net> wrote:
>> On 11/22/2012 12:29 PM, Jean-vincent.Loddo@lipn.univ-paris13.fr 
>> wrote:
>>> 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?
>>
>> Its the documented behavior:
>> http://caml.inria.fr/pub/docs/manual-ocaml/libref/Lazy.html
>>
>> Unfortunately the original backtrace will be lost.
>>
>> --Edwin
>>
>> --
>> Caml-list mailing list.  Subscription management and archives:
>> https://sympa.inria.fr/sympa/arc/caml-list
>> Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
>> Bug reports: http://caml.inria.fr/bin/caml-bugs

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

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-11-22 10:29 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 message]

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=cd07e4672b830d6fc91f5f691b057ab8@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).