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

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

Expand Messages
  • Jon Harrop
    Feb 2, 2008
    • 0 Attachment
      On Saturday 02 February 2008 20:52:57 Martin DeMello wrote:
      > The exact problem is I'd
      > like dawg to be defined as a global variable in main.ml but be visible
      > from functions in another file, though if there's a better way to do
      > things I'd love to hear that too.

      Yes: take "dawg" out of the "main" file and put it in its own file that
      everything using it can depend upon.

      This is typically done for the definition of an "expr" type that must be
      visible both in a parser and in an evaluator.

      In more complicated situations you can also parameterize your code over the
      definitions that it uses via functors rather than higher-order functions.
      This was discussed in the latest OCaml Journal article.

      --
      Dr Jon D Harrop, Flying Frog Consultancy Ltd.
      http://www.ffconsultancy.com/products/?e
    • Show all 12 messages in this topic