* Arg.spec and option types
@ 2007-03-22 14:56 Nicolas barnier
2007-03-22 20:32 ` Sam Steingold
0 siblings, 1 reply; 3+ messages in thread
From: Nicolas barnier @ 2007-03-22 14:56 UTC (permalink / raw)
To: Caml list
Hi list,
I find the recent addition of the Set_{string|int|float} constructors
of type Arg.spec quite useful, as it spares a lot of repeated code
for processing command line arguments. However, for optional arguments,
I often feel the need (and write the code) to handle option types,
which can elegantly be processed to trigger optional behaviours of a
program.
I think it would therefore be quite useful to add
Set_option_{string|int|float}
constructors which would expect {string|int|float} option ref values as
arguments (usually initialized with None). Do others think the same or use
some other workaround to obtain this behaviour ?
-- Nicolas
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Arg.spec and option types
2007-03-22 14:56 Arg.spec and option types Nicolas barnier
@ 2007-03-22 20:32 ` Sam Steingold
2007-03-22 20:46 ` [Caml-list] " Nicolas Pouillard
0 siblings, 1 reply; 3+ messages in thread
From: Sam Steingold @ 2007-03-22 20:32 UTC (permalink / raw)
To: Nicolas barnier; +Cc: Caml list
Nicolas barnier wrote:
>
> I think it would therefore be quite useful to add
> Set_option_{string|int|float}
> constructors which would expect {string|int|float} option ref values as
> arguments (usually initialized with None). Do others think the same or use
> some other workaround to obtain this behaviour ?
It is nice to know that I am not the only one who is writing
Arg.String (fun s -> foo := Some s)
all the time.
Sam.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Caml-list] Re: Arg.spec and option types
2007-03-22 20:32 ` Sam Steingold
@ 2007-03-22 20:46 ` Nicolas Pouillard
0 siblings, 0 replies; 3+ messages in thread
From: Nicolas Pouillard @ 2007-03-22 20:46 UTC (permalink / raw)
To: Sam Steingold; +Cc: Nicolas barnier, Caml list
On 3/22/07, Sam Steingold <sds@gnu.org> wrote:
> Nicolas barnier wrote:
> >
> > I think it would therefore be quite useful to add
> > Set_option_{string|int|float}
> > constructors which would expect {string|int|float} option ref values as
> > arguments (usually initialized with None). Do others think the same or use
> > some other workaround to obtain this behaviour ?
>
> It is nice to know that I am not the only one who is writing
> Arg.String (fun s -> foo := Some s)
> all the time.
>
> Sam.
>
What about,
let opt_str r = Arg.String (fun s -> r := Some s);;
... opt_str foo ...
That's what I use all the time.
--
Nicolas Pouillard
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2007-03-22 20:46 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-03-22 14:56 Arg.spec and option types Nicolas barnier
2007-03-22 20:32 ` Sam Steingold
2007-03-22 20:46 ` [Caml-list] " Nicolas Pouillard
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox