From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail1-relais-roc.national.inria.fr (mail1-relais-roc.national.inria.fr [192.134.164.82]) by walapai.inria.fr (8.13.6/8.13.6) with ESMTP id q2DAnmKq016814 for ; Tue, 13 Mar 2012 11:49:48 +0100 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AokBAL8lX0/RVdc2kGdsb2JhbABDrGQBiHMIIgEBAQEJCQ0HFAQjgiICExkBGx4DEgkBBl0BEQEFAT0ah2icWYJdCot4gnGFLj+IdAEFC404gyIElU+ORT2EBw X-IronPort-AV: E=Sophos;i="4.73,575,1325458800"; d="scan'208";a="149049821" Received: from mail-lpp01m010-f54.google.com ([209.85.215.54]) by mail1-smtp-roc.national.inria.fr with ESMTP/TLS/RC4-SHA; 13 Mar 2012 11:49:43 +0100 Received: by lagv3 with SMTP id v3so633826lag.27 for ; Tue, 13 Mar 2012 03:49:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:from:date:message-id:subject:to:content-type; bh=awPEzwdjNDqfTfdYVFQhIb7/lLOib7d2RprAvRVlnWE=; b=0crnRVnmI+7ULgYc2Qg4MyXJXTUnhnHb1mkL4w92kC9yOYEEZyzb6vnWzc8ievNA/6 jGaS/rFP4wi58X4N6BHRbLnDIeHerdJgBJ93GEULLqbg7eQXbifaB6RTIg8B/9hVxXKX IoSNok3kMoOB1DCXWhKPM2o7VRYWca4ZVh68cnUzr+wmZdpy/z0PyEwB0xFlYNpAVsox m7Pr0JYWoLEWmmwiaow3hj+nmpVbLaS7bOpIv7VIr0AgV6gZi/nOJNeN4YJgZyLkPegC MFEF11Yo302hS0m/ZWcaaU1X/mBjcaAxMUCOsfNhg36iyO0HCUp9ApzxUE2xxF8n1x3J +1TQ== Received: by 10.152.128.38 with SMTP id nl6mr11821340lab.15.1331635782239; Tue, 13 Mar 2012 03:49:42 -0700 (PDT) MIME-Version: 1.0 Received: by 10.152.25.73 with HTTP; Tue, 13 Mar 2012 03:49:10 -0700 (PDT) From: Gabriel Cardoso Date: Tue, 13 Mar 2012 11:49:10 +0100 Message-ID: To: caml-list@inria.fr Content-Type: multipart/alternative; boundary=f46d043086c0c5444304bb1d9de2 Subject: [Caml-list] Problem with Arg.Tuple --f46d043086c0c5444304bb1d9de2 Content-Type: text/plain; charset=ISO-8859-1 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 !!! *) (* Arg.String (fun ss -> f !s ss) (\* Works just fine ... why ? *\) *) ], "doc" )] let _ = Arg.parse speclist (fun s -> ()) "usage" -------------------- $ ocamlc test.ml $ /a.out -a x y y ------------------------ When uncommenting the line 12 : ------------------------ $ ocamlc test.ml $ ./a.out -a x y x y ------------------------- Any idea what am I doing wrong ? Thanks in advance ! Gabriel --f46d043086c0c5444304bb1d9de2 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable
Dear list,=A0

I have empty arguments whe= n using Arg.Tuple with references. This minimalist example illustrates my p= roblem :

let f a b =3D
=A0 print_endline= a;
=A0 print_endline b

let s =3D ref ""= ;

let speclist =3D [(
=A0 "-a"= ,
=A0 Arg.Tuple [
=A0 =A0 Arg.Set_string s;
= =A0 =A0 Arg.String (f !s) (* !s is empty !!! *)
=A0 =A0 (* Arg.String (fun ss -> f !s ss) (\* Works just fine ... w= hy ? *\) *)
=A0 ],
=A0 "doc"
)]

let _ =3D Arg.parse speclist (fun s -> ()) "u= sage"

--------------------
$ ocamlc test.ml
$ /a.out -a x y

y
------------------------

When uncommenti= ng the line 12 :=A0
------------------------
$ ocamlc test.ml
$ ./a.out -a x y
x
y
----= ---------------------

Any idea what am I doing wro= ng ?

Thanks in advance !

Gabriel
--f46d043086c0c5444304bb1d9de2--