> On Thu, Sep 08, 2005 at 04:00:47PM +0000, [EMAIL PROTECTED] wrote:
>> $ cat bug.hs
>> main = print (let (x,(q,_)) = (1,divMod x x) in q)
>> $ runhugs bug.hs
>> Illegal instruction (core dumped)
>
> Not entirely innocent: demand for x also causes evaluation of the second
> pair, which depends on x: an infinite loop. The correct version is
>
> main = print (let (x,~(q,_)) = (1,divMod x x) in q)
This is a valuable clue. I previously thought that rewriting
let <a> = <b>
<c> = <d> in <e>
as
let (<a>,<c>) = (<b>,<d>) in <e>
is harmless, but section 3.12 of the Report says different.
I still don't understand why
main = print (let (x,(q,_)) = (1,divMod x x) in q)
and
main = print (let (x,(q,_)) = (1,divmod x x) in q)
divmod x y = (div x y,mod x y)
behave differently. Please give me another clue. Thank you.
_______________________________________________
Hugs-Bugs mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/hugs-bugs