[Haskell-cafe] Re: [Haskell] Top Level <-
ashley at semantic.org
Sat Aug 30 07:42:16 EDT 2008
Ganesh Sittampalam wrote:
> Every single call to newIORef, across the whole world, returns a
> different ref.
How do you know? How can you compare them, except in the same Haskell
> The "same" one as a previous one can only be returned
> once the old one has become unused (and GCed).
Perhaps, but internally the IORef is a pointer value, and those pointer
values might be the same. From the same perspective, one could say that
every single call to newUnique across the whole world returns a
different value, but internally they are Integers that might repeat.
>> It's the scope in which values from newUnique are supposed to be
>> different, and it would also be the scope in which top-level <- would
>> be called at most once.
> I don't really follow this. Do you mean the minimal such scope, or the
> maximal such scope? The problem here is not about separate calls to
> newIORef, it's about how many times an individual <- will be executed.
Two IO executions are in the same "global scope" if their resulting
values can be used in the same expression. Top-level <- declarations
must execute at most once in this scope.
More information about the Haskell-Cafe