I totally agree with Derek. Which exception you get can vary with compiler version, compiler flags, time of day, phase of the moon, ...<br>It will be one in a set of exceptions, but you don't know which one.<br><br> -- Lennart
<br><br><div class="gmail_quote">On Nov 18, 2007 8:34 PM, Derek Elkins <<a href="mailto:derek.a.elkins@gmail.com">derek.a.elkins@gmail.com</a>> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div><div></div><div class="Wj3C7c">On Sun, 2007-11-18 at 12:11 -0800, Iavor Diatchki wrote:<br>> Hello,<br>><br>> I was playing around with "bang patterns" and I noticed that<br>> when combined with asynchronous exceptions they can lead to
<br>> programs where the order of the declarations in a binding<br>> group is important! Here is an example:<br>><br>> > import Control.Exception<br>> > import Prelude hiding (catch)<br>> ><br>
> > main = putStrLn =<< eval_order<br>> ><br>> > test = "no exception"<br>> > where !_ = error "top down"<br>> > !_ = error "bottom up"<br>> >
<br>> > eval_order = evaluate test `catch` \e -><br>> > case e of<br>> > ErrorCall txt -> return txt<br>> > _ -> throw e<br>>
<br>> Of course, this is a contrived exampled but, as far as I know,<br>> this was not possible in Haskell before (if anyone has an example<br>> to the contrary please send it to the list).<br>><br>> By the way, with GHC
6.8.1 the above program prints "bottom up".<br>> This means that when there are multiple "banged" bindings they<br>> are evaluated starting with the last one in the text. I imagine<br>> than in most programs this is not particularly important, but
<br>> it seems to me that it would be a bit nicer if we were to adjust<br>> the translation so that bindings were evaluated top to bottom<br>> (e.g., like in ML).<br><br></div></div>The whole point of the "imprecise exceptions" paper was that any
<br>exception may be returned when multiple ones could be. There is no<br>reason why the bindings should be evaluated top-down. If you are<br>relying on the order the bindings are evaluated you are doing something<br>very, very wrong. Should we also specify what exception should be
<br>thrown for error "left-right" + error "right-left" ?<br><div><div></div><div class="Wj3C7c"><br>_______________________________________________<br>Haskell mailing list<br><a href="mailto:Haskell@haskell.org">
Haskell@haskell.org</a><br><a href="http://www.haskell.org/mailman/listinfo/haskell" target="_blank">http://www.haskell.org/mailman/listinfo/haskell</a><br></div></div></blockquote></div><br>