|
Boost : |
From: Thorsten Ottosen (nesotto_at_[hidden])
Date: 2004-03-19 08:41:09
Hi again,
> Section "Tutorial"
> ------------------------
>
> 1. I don't like that the example hardcodes strings.
Could you explain?
---------
writing
const char* help = "help";
would enable the compiler to catch spell-errors in the constants.
> 2. each line should have a comment about what it does.
Actually, that would duplicate explanations that are already in the
tutorial.
Don't you think?
------------------
I'm in doubt :-) I do like comments because they can easily be compared to
code; when you're reading
block text, it can be harder to focus on where the comments apply.
> 9. Could this way of specifying composing()/default_value() be of any use
>
> option += option<int>( "xx", "xx msg" ), option_with_default<int>( ""yy",
> var_name, 0, "yy msg" ),
> option_with_compose< vector<string> >( "zz", "zz msg" );
>
> ?.
I think that syntantically, it requires the same number (or even larger)
number of characters. Besides, what if you want to specified both default
value and 'composing' flags? options_with_default_and_compose looks too
long.
---------
yeah, then what about
option += option<int>( ""xx"", var_name, compose_flag | other_flag )
? That use of flags might be more idiomatic.
> 10. This
>
> po::options_description cmdline_options;
> cmdline_options.add(generic).add(config).add(hidden);
>
> might be
>
> po::options_description cmdline_options;
> cmdline_options += generic, config, hidden;
>
> ?
Interesting! I just found some-years-old code of mine which provides support
for such initialization. It worked for vectors, like:
v << 1, 2, 3, 4, 5, 6;
but can be easily used for +=, too. I'm just not sure this is justified
here.
--------------
Actually, one could choose to use my assign library if it gets accepted.
You would probably only have to write one overload of operator+= so
it can recognize your types. There is also another use. Let's say you
make a function add():
program_options po;
add( po )( "xx", df, "xx msg)(...)(...)
that should work ou of the box with different tuplesizes. Making add() and
operator+()
is about the same amount of work, probably 3-4 four lines each.
br
Thorsten
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk