>  > timeStarted = performOnceBeforeMain (getCurrentTime)
>  > 
>  > Just like that one would do with unsafePerformIO, but with
>  > safer semantics (hopefully) and blessed by Standard Haskell.
> 
> I see some serious problems:
> 
>   a = (performOnceBeforeMain m1,performOnceBeforeMain m2)
> 
> In which order are m1 and m2 performed?
> 

Don't know. Maybe it could be acceptable to define it to be
nondeterministic, like for the relative interleaving of the branches
of forkIO. (Which isn't standard Haskell either...)

> 
>   f x = performOnceBeforeMain x
> 
> What does this mean?
> 

Don't know. Maybe it means a run-time error: I'd think that the system
could detect that there is an occurence of performOnceBeforeMain that
was not possible to reduce before Main started.

> Even if we only allow performOnceBeforeMain in declarations of the form
> 
>    <name> = performOnceBeforeMain <expr>
> 

Yes, this seems to be a safer form.

> in which order should such declarations be performed?
> 
  

How about only allowing one call to performOnceBeforeMain in your
program? It may be a little awkward from a software-engineering
point but...

module Constants where
(options, startTime, addressBook, etc) = performOnceBeforeMain <expr>

I don't see these problems as more serious than the very concept
of making things from the environment, in general, available as
constants in your program.

If we could have the Environment variables as constants, and can solve
the semantic difficulties associated with that, and the other problems
that might occur, then I think we should amortize this work on a
general mechanism.

So that you could for example have a constant look-up table array
available, read from a file of several megabytes.  (Impossible to pass
in the Environment, unless you make some really radical changes to
some system-defined constants, in the Unix Kernel I think.)

(Personally, _I_ would like to get at least that benefit for the work
that I think I will have to do to redesign my Haskell persistency
library almost from scratch, which would be needed if we made the
Environment constant :-)

Sverker



Reply via email to