Version française
Home     About     Download     Resources     Contact us    
Browse thread
global record
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Yoann Padioleau <padator@w...>
Subject: Re: [Caml-list] global record
Richard Jones <rich@annexia.org> writes:

> On Wed, Jul 19, 2006 at 01:11:22PM +0200, Andreas Biegert wrote:
>> I am developing a bioinformatics sequence analysis application which
>> contains about 20 modules. One of those modules, the 'Par' module,
>> encapsulates a record of about 30 configuration parameters needed
>> throughout the whole application. The parameter record is mostly
>> static but some values can be overwritten by command-line options. Is
>> there a way to make the (possibly modified) parameters record globally
>> accessable throughout all modules? This would be much more convenient
>> than having to pass the parameters record to virtually all functions
>> in my application. THX for helping.
>
> This is a bit ugly, but we use it in our Adwords API toolkit:
>
> -------------------------------------------------- stdargs.mli
> val username : string

You certainly mean 
 val username: string ref

> val password : string
> val client : string option
> val token : string
> val update : bool
> val verbose : bool
> val args : string list
>
> -------------------------------------------------- stdargs.ml
> let username = ref ""
> let password = ref ""
> let client = ref ""
> let token = ref ""
> let update = ref false
> let verbose = ref false
> let args = ref []
>

[ ... ]
>
> Then the code just stuff like:
>
>   open Stdargs
>
>   if verbose then printf "this is verbose mode\n"

You certainly mean 

 if !verbose then printf "this is verbose mode\n"

>
> Rich.

-- 
pad