caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: "Till Varoquaux" <till.varoquaux@gmail.com>
To: "Michael Wohlwend" <micha-1@fantasymail.de>
Cc: caml-list@yquem.inria.fr, mulhern <mulhern@gmail.com>
Subject: Re: [Caml-list] Use Arg module to read keyword followed by unspecified number of arguments
Date: Tue, 23 May 2006 21:50:16 +0200	[thread overview]
Message-ID: <9d3ec8300605231250g6e37b8a2jcb06cde87fd3eef9@mail.gmail.com> (raw)
In-Reply-To: <200605232121.25349.micha-1@fantasymail.de>

Actualy I'd stick with double references... (yuck). From the top of my head:
let a=ref [];;
let b=ref [];;
let c=ref a;;

let p_list l=
        List.iter (Printf.printf "\"%s\"") l;
        print_newline ()

let _=
        Arg.parse [("-switch",Arg.Unit (fun () -> c:=b),"")]
                (fun s -> !c:=s::!(!c))
                "blah";
        p_list !a;
        p_list !b

Note how c is a double reference...

Till

On 5/23/06, Michael Wohlwend <micha-1@fantasymail.de> wrote:
> On Tuesday 23 May 2006 19:17, mulhern wrote:
> > Hi!
> >
> > I expect to be reading something like this:
> >
> > -pred-files <arg1> <arg2> ... <argn> -key2 <arg> -extra-files <arg1>
> > <arg2> ... <argn> -key4
>
> I think the idea by Till to separate the args with commas is best, but if you
> don't want to do this, maybe something like that would be o.k. :
>
> let mode_pred = ref true;;
> let pred_files = ref [];;
> let extra_files = ref [];;
> let key2 = ref "";;
>
> Arg.parse [
>         "-extra-files", Arg.Clear mode_pred, "extra files";
>         "-key2", Arg.Set_string key2, "key2";
>         "-pred-files", Arg.Set mode_pred, "pred files"
>         ]
>         (fun name -> if !mode_pred then
>                         pred_files := name :: !pred_files
>                 else
>                         extra_files := name :: !extra_files
>         ) "usage..."
> ;;
>
>
> cheers,
>  Michael
>
>
> --
> C offers you enough rope to hang yourself.
> C++ offers a fully equipped firing squad, a last cigarette and
> a blindfold.
>
> _______________________________________________
> Caml-list mailing list. Subscription management:
> http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list
> Archives: http://caml.inria.fr
> Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
> Bug reports: http://caml.inria.fr/bin/caml-bugs
>


  reply	other threads:[~2006-05-23 19:50 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-05-23 17:17 mulhern
2006-05-23 17:29 ` [Caml-list] " Till Varoquaux
2006-05-23 17:49 ` Oliver Bandel
2006-05-23 17:55 ` Oliver Bandel
2006-05-23 19:21 ` Michael Wohlwend
2006-05-23 19:50   ` Till Varoquaux [this message]
2006-05-23 19:57     ` Michael Wohlwend
2006-05-24 14:03 ` Richard Jones

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=9d3ec8300605231250g6e37b8a2jcb06cde87fd3eef9@mail.gmail.com \
    --to=till.varoquaux@gmail.com \
    --cc=caml-list@yquem.inria.fr \
    --cc=micha-1@fantasymail.de \
    --cc=mulhern@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).