[Haskell-cafe] Re: Global Variables and IO initializers

Benjamin Franksen benjamin.franksen at bessy.de
Wed Nov 24 19:48:40 EST 2004


On Thursday 25 November 2004 01:14, Ben Rudiak-Gould wrote:
> Benjamin Franksen wrote:
>  >    label1 = unique Uniq1
>  >    label2 = unique Uniq2
>  >    global1 = functionalNewMVar label1 True
>  >    global2 = functionalNewMVar label1 (117::Int)
>
> No dice. Your example inadvertently shows why: you used label1 when
> creating both global1 and global2, and now I can write
>
>     coerce :: Bool -> Int
>     coerce x = putMVar global1 x >> takeMVar global2
>
> (provided I've emptied them first).

My god, what a stupid mistake. I should just give it up... :-(

Ben


More information about the Haskell-Cafe mailing list