From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by yquem.inria.fr (Postfix) with ESMTP id 320F0BBAF for ; Wed, 19 Jul 2006 16:39:47 +0200 (CEST) Received: from ron.emn.fr (sicnat2.emn.fr [193.54.76.193]) by nez-perce.inria.fr (8.13.6/8.13.6) with ESMTP id k6JEdkam029211 for ; Wed, 19 Jul 2006 16:39:46 +0200 Received: from spip.dsic.emn.fr (root@spip.dsic.emn.fr [193.104.32.156]) by ron.emn.fr (8.9.3/jtpda-5.3.1) with ESMTP id QAA12431 ; Wed, 19 Jul 2006 16:38:35 +0200 (CEST) Received: from ifs.emn.fr (ifs.emn.fr [193.54.76.100]) by spip.dsic.emn.fr (8.12.1/8.12.1) with ESMTP id k6JEdebT029748; Wed, 19 Jul 2006 16:39:40 +0200 Received: from localhost.localdomain (pad@dhcp109.rech18.emn.fr [192.168.18.109]) by ifs.emn.fr (8.9.3/jtpda-5.1) with ESMTP id QAA00696 ; Wed, 19 Jul 2006 16:38:15 +0200 (MEST) To: Richard Jones Cc: Andreas Biegert , caml-list@yquem.inria.fr Subject: Re: [Caml-list] global record References: <20060719140729.GA26227@furbychan.cocan.org> From: Yoann Padioleau Date: Wed, 19 Jul 2006 16:39:32 +0200 In-Reply-To: <20060719140729.GA26227@furbychan.cocan.org> (Richard Jones's message of "Wed, 19 Jul 2006 15:07:29 +0100") Message-ID: <871wshveu3.fsf@wanadoo.fr> User-Agent: Gnus/5.1007 (Gnus v5.10.7) Emacs/21.4 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-j-chkmail-Score: MSGID : 44BE4432.000 on nez-perce : j-chkmail score : X : 0/20 1 X-Miltered: at nez-perce with ID 44BE4432.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; overwritten:01 command-line:01 api:01 mli:01 val:01 val:01 bool:01 verbose:01 bool:01 verbose:01 printf:01 printf:01 2006:98 wrote:01 writes:01 X-Spam-Checker-Version: SpamAssassin 3.0.3 (2005-04-27) on yquem.inria.fr X-Spam-Level: * X-Spam-Status: No, score=1.8 required=5.0 tests=DNS_FROM_RFC_ABUSE, DNS_FROM_RFC_POST,FORGED_RCVD_HELO autolearn=disabled version=3.0.3 Richard Jones 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