Loading ...
Sorry, an error occurred while loading the content.

9316Re: "ocaml_beginners"::[] getting rid of a global variable

Expand Messages
  • Jon Harrop
    Feb 3, 2008
    • 0 Attachment
      On Sunday 03 February 2008 14:06:11 Martin DeMello wrote:
      > On Feb 3, 2008 3:31 PM, Richard Jones <rich@...> wrote:
      > > 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.

      You might also like to try:

      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.
    • Show all 12 messages in this topic