9316Re: "ocaml_beginners":: getting rid of a global variable
- Feb 3, 2008On Sunday 03 February 2008 14:06:11 Martin DeMello wrote:
> On Feb 3, 2008 3:31 PM, Richard Jones <rich@...> wrote:You might also like to try:
> > If you want the database file to be read at a controlled point later,
> > or you want to allow the user to interactively set the filename, then
> > you can do it with a global reference initialized like this:
> > let dawg = ref None ;;
> Thanks, that works nicely. I'm taking an extra dereference hit every
> time I access the dawg, but I can always optimise later.
let dawg = lazy (Array. ...)
and accessing it with "Lazy.force dawg". The code is then evaluated only the
first time it is used.
Dr Jon D Harrop, Flying Frog Consultancy Ltd.
- << Previous post in topic Next post in topic >>