From: Michael Hicks <firstname.lastname@example.org>
Subject: Re: one-time initialization
To: email@example.com (John Prevost)
Date: Thu, 28 Jan 1999 09:47:04 -0500 (EST)
In-Reply-To: <firstname.lastname@example.org> from "John Prevost" at Jan 28, 99 04:54:07 am
> val global = (ref (fun () -> failwith "not initialized") :
> (mytype -> unit) ref)
> let init i = global := fun () -> i
> let f () = ... (!global ())
> let g () = (!global ()) ...
> this at least has the advantage that you don't have to have a big
> hairy pattern match in every function.
I've tried this and similar alternatives using classes and records, but they
all end up being slower than the naive approach I presented before. :(
One thing I've thought of is to make the entire program a bunch of functors,
parameterized by their external module references and an additional
"initialization information" module. Then, the toplevel "main" module would
execute some code to initialize the "initialization" module, and then invoke
all of the functors to construct a custom program based on the
initialization information. Since my program is a long-running server
application, it might be worth this one-time cost. On the other hand, I'm
not sure the gain will be worth re-architecting the whole program ...
-- Michael Hicks Ph.D. Candidate, the University of Pennsylvania http://www.cis.upenn.edu/~mwh mailto://email@example.com "I worked with an individual who plugged his power strip back into itself and for the life of him could not understand why his computer would not turn on."
This archive was generated by hypermail 2b29 : Sun Jan 02 2000 - 11:58:18 MET