Boost logo

Boost :

From: David Abrahams (dave_at_[hidden])
Date: 2003-05-28 10:15:44

"Rozental, Gennadiy" <gennadiy.rozental_at_[hidden]> writes:

>>>> desc.add_options()
>>>> // first argument is options name
>>>> // second argument is parameter name
>>>> // third argument is description
>>>> ("output", "file", "output file")
>>>> ....
>>>> ;
>>>> This means that one comment line is added for first argument, and
>>>> then you can very conveniently specify option name.
>>> Poor maintenance programmer looked on this code and spread hands
>>> puzzled: What is option name and what is parameter name???? Which
>>> one should I use to identify argument? Where the value assigned?
>>> What is default value?
>>Sorry, but this kind of questions can be answered only in docs.
> Sorry. But this is not good enough for me.
> In my terms above would look like this:
> parameter<std::string>( "output" )
> << place_to( output_file_name )
> << default_value( "/tmp/abc" )
> << description( "output file name" )

While I don't find the interface proposed by Vladimir to be offensive,
when you get a pile of function arguments of the same type together a
named parameter interface *can* be a help. I don't think I'd use
operator<<, though. If it's really about readability I'd tend to
sacrifice some non-intrusive extensibility for a cleaner syntax:

     parameter<std::string>( "output" )
       .place_to( output_file_name )
       .default_value( "/tmp/abc" )
       .description( "output file name" )

But anyway, neither of these looks like a huge win over a function
which simply takes 3 parameters. Probably the complexity isn't

Dave Abrahams
Boost Consulting

Boost list run by bdawes at, gregod at, cpdaniel at, john at