caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] Problem with Arg.Tuple
@ 2012-03-13 10:49 Gabriel Cardoso
  2012-03-13 11:21 ` Samuel Hornus
       [not found] ` <070E17B9-F989-4184-A702-7D323710F52B@inria.fr>
  0 siblings, 2 replies; 3+ messages in thread
From: Gabriel Cardoso @ 2012-03-13 10:49 UTC (permalink / raw)
  To: caml-list

[-- Attachment #1: Type: text/plain, Size: 705 bytes --]

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

[-- Attachment #2: Type: text/html, Size: 1301 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2012-03-13 12:24 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-03-13 10:49 [Caml-list] Problem with Arg.Tuple Gabriel Cardoso
2012-03-13 11:21 ` Samuel Hornus
     [not found] ` <070E17B9-F989-4184-A702-7D323710F52B@inria.fr>
2012-03-13 12:23   ` Gabriel Cardoso

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).