From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail4-relais-sop.national.inria.fr (mail4-relais-sop.national.inria.fr [192.134.164.105]) by walapai.inria.fr (8.13.6/8.13.6) with ESMTP id q2DBR71R018692 for ; Tue, 13 Mar 2012 12:27:07 +0100 Resent-Message-Id: <201203131127.q2DBR71R018692@walapai.inria.fr> X-IronPort-AV: E=Sophos;i="4.73,575,1325458800"; d="scan'208";a="135793113" Received: from rhodamine.loria.fr ([152.81.2.177]) by mail4-relais-sop.national.inria.fr with ESMTP/TLS/AES128-SHA; 13 Mar 2012 12:27:01 +0100 Mime-Version: 1.0 (Apple Message framework v1257) Content-Type: text/plain; charset=windows-1252 From: Samuel Hornus Resent-From: Samuel Hornus In-Reply-To: Date: Tue, 13 Mar 2012 12:21:12 +0100 Resent-Date: Tue, 13 Mar 2012 12:27:01 +0100 Message-Id: References: Resent-To: O Caml To: Gabriel Cardoso X-Mailer: Apple Mail (2.1257) Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from quoted-printable to 8bit by walapai.inria.fr id q2DBR71R018692 Subject: Re: [Caml-list] Problem with Arg.Tuple On Mar13, 2012, at 11:49 , Gabriel Cardoso wrote: > Dear list, > > I have empty arguments when using Arg.Tuple with references. This minimalist example illustrates my problem : > > let f a b = > print_endline a; > print_endline b > > let s = ref "" > > let speclist = [( > "-a", > Arg.Tuple [ > Arg.Set_string s; > Arg.String (f !s) (* !s is empty !!! *) Here, the value of !s is empty when the (f !s) is evaluated… you shoud pass the whole reference as argument : Arg.String(f s) and let f a b = print_endline !a; print_endline b > (* Arg.String (fun ss -> f !s ss) (\* Works just fine ... why ? *\) *) why ? because the !s is evaluated only later, when the anonymous function (fun ss ->…) is applied. -- Sam