9311Re: "ocaml_beginners":: getting rid of a global variable
- Feb 2, 2008On Saturday 02 February 2008 20:52:57 Martin DeMello wrote:
> The exact problem is I'dYes: take "dawg" out of the "main" file and put it in its own file that
> 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.
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.
- << Previous post in topic Next post in topic >>