Sverker Nilsson <[EMAIL PROTECTED]> wrote:

> So if it turns out to be possible to make the environment a constant,
> it should open up possibilities for other constants as well. I
> would rather see a general mechanism. Something like:
> 
> performOnceBeforeMain:: IO a -> a
> 
> timeStarted = performOnceBeforeMain (getCurrentTime)
> 
> Just like that one would do with unsafePerformIO, but with
> safer semantics (hopefully) and blessed by Standard Haskell.

I agree.  Even if this particular mechanism needs some extra
restrictions to be safe I would prefer this to the hack of
just making argv a global constant.  This is a hack too, but
at least it's generalized.


In general I agree with the points made by Frank Christoph about why
argv as a global constant is undesirable.  If you'd asked me a few 
years ago I would have been on the other side of the fence.  I remember
discussing this with Simon walking on some back streets in Glasgow.
I argued exactly the case that Simon and Sigbj?rn are doing now, about
how convenient it would be.  And it is indeed convenient sometimes.
I've sinced changed my mind, maybe it is "a functional programmers
deathwish", but I find the case where you are explicit about what a
function depends on to be more honest and true to the FP spirit.
I've also found it practically useful since you can then change the
values of the given flags locally (which you couldn't do with a global
argv).

        -- Lennart



Reply via email to