[Haskell-cafe] Current situation regarding global IORefs

Lennart Augustsson lennart at augustsson.net
Sun Apr 23 11:18:31 EDT 2006


Robert Dockins wrote:
> <ramble type="somewhat coherent">
> Ahhh... the singleton pattern.  There is a debate among OO theorists 
> about whether the singleton pattern is actually a good idea.  I tend to 
> side with those who say that it is Just Wrong.  The reality is that 
> "singletons" are only unique within some scope (OS process, VM, sandbox, 
> whatever).  "Global" state is similar; it is always bounded by 
> _something_.  I think its always better to make the boundaries explicit 
> and aligned with the problem domain rather than implicit, because the 
> implicit boundaries sometimes/often don't do what you want.  As soon as 
> you have an even slightly unusual execution environment, your 
> assumptions can be violated (eg, within Java application containers 
> *shudder*).  I have to imagine using, eg, HS plugins with modules 
> containing top-level state could cause all sorts of havoc.
> </ramble>

I couldn't have rambled it better myself. :)
I think global mutable variables should be regarded with utmost
suspicion.  There are very few situations where they are the
right solution.

	-- Lennart


More information about the Haskell-Cafe mailing list