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 9B501BB83 for ; Tue, 23 May 2006 21:50:17 +0200 (CEST) Received: from wx-out-0102.google.com (wx-out-0102.google.com [66.249.82.197]) by nez-perce.inria.fr (8.13.0/8.13.0) with ESMTP id k4NJoGuU006854 for ; Tue, 23 May 2006 21:50:17 +0200 Received: by wx-out-0102.google.com with SMTP id i27so931233wxd for ; Tue, 23 May 2006 12:50:16 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=dG8+P60ezPuCkK4WOEzZ0H/r1PIw+mWV15Q/JjyrwjWzE/dvwGhyHyfafXqDhWtqyI4h3GDmTptJl6xxi2oV3ybVW8Zhjwvjt+f7r02/jKjqLLp1WnDwGnIKrs9MIF+W8N+thIPkVYvZQMd4UT0ZAIsVfzzsG71FRmur2wV65/4= Received: by 10.70.70.5 with SMTP id s5mr6792626wxa; Tue, 23 May 2006 12:50:16 -0700 (PDT) Received: by 10.70.125.16 with HTTP; Tue, 23 May 2006 12:50:16 -0700 (PDT) Message-ID: <9d3ec8300605231250g6e37b8a2jcb06cde87fd3eef9@mail.gmail.com> Date: Tue, 23 May 2006 21:50:16 +0200 From: "Till Varoquaux" To: "Michael Wohlwend" Subject: Re: [Caml-list] Use Arg module to read keyword followed by unspecified number of arguments Cc: caml-list@yquem.inria.fr, mulhern In-Reply-To: <200605232121.25349.micha-1@fantasymail.de> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: quoted-printable Content-Disposition: inline References: <54f15b6e0605231017o5f23fd07q7f7b1c5cab38cf0b@mail.gmail.com> <200605232121.25349.micha-1@fantasymail.de> X-j-chkmail-Score: MSGID : 44736778.000 on nez-perce : j-chkmail score : X : 0/20 1 X-Miltered: at nez-perce with ID 44736778.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; unspecified:01 iter:01 printf:01 printf:01 commas:01 pred:01 pred:01 cheers:01 beginner's:01 ocaml:01 beginners:01 bug:01 2006:98 squad:98 cigarette:98 X-Spam-Checker-Version: SpamAssassin 3.0.3 (2005-04-27) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=RCVD_BY_IP autolearn=disabled version=3.0.3 Actualy I'd stick with double references... (yuck). From the top of my head= : let a=3Dref [];; let b=3Dref [];; let c=3Dref a;; let p_list l=3D List.iter (Printf.printf "\"%s\"") l; print_newline () let _=3D Arg.parse [("-switch",Arg.Unit (fun () -> c:=3Db),"")] (fun s -> !c:=3Ds::!(!c)) "blah"; p_list !a; p_list !b Note how c is a double reference... Till On 5/23/06, Michael Wohlwend wrote: > On Tuesday 23 May 2006 19:17, mulhern wrote: > > Hi! > > > > I expect to be reading something like this: > > > > -pred-files ... -key2 -extra-files > > ... -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 =3D ref true;; > let pred_files =3D ref [];; > let extra_files =3D ref [];; > let key2 =3D 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 :=3D name :: !pred_files > else > extra_files :=3D 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 >