[Haskell] thread-local variables

Taral taralx at gmail.com
Sun Aug 6 13:25:12 EDT 2006


On 8/5/06, Frederik Eaton <frederik at a5.repetae.net> wrote:
> Also, note that my proposal differs in that thread local variables are
> not writable, but can only be changed by calling (e.g. in my API)
> 'withIOParam'.
[snip]
> and if some library I use decides
> to fork a thread behind the scenes, it won't change my program's
> behavior.

Yes, but if it passes your action to another pre-existing thread, it will.

What people seem to want is dynamic scoping. Why not implement that
instead of messing around with yucky thread stuff?

data IODynamicRef a

getDynamicRef :: IODynamicRef a -> IO a
setDynamicRef :: IODynamicRef a -> a -> IO b -> IO b

-- 
Taral <taralx at gmail.com>
"You can't prove anything."
    -- Gödel's Incompetence Theorem


More information about the Haskell mailing list