|
Boost : |
Subject: Re: [boost] [local] Review (and resignation from review assistant)
From: Andrzej Krzemienski (akrzemi1_at_[hidden])
Date: 2011-11-21 09:41:59
> > - What is your evaluation of the design?
> The library is very well designed. The function declaration syntax looks
a little foreign at first, but it is very easy to get used to.
Furthermore, error messages are usually able to point you to what you did
wrong. The fact that you can write the body of the function in plain C++
code is a major advantage of this library. Some have referred to
Boost.Bind, Boost.Lambda and Boost.Phoenix as essentially being equivalent
to this library, but in none of those libraries can you express the body of
your function in plain C++; one advantage of this is that errors in your
code result in normal C++ error messages rather than cryptic error messages.
Lorenzo, given this comment by Greg, I do have one more suggestion for
documentation (or did someone already say it?). Given the heated discussion
of whether Boost.Bind, Boost.Lambda and Boost.Phoenix are sufficient to
render Boost.Local unnecessary, perhaps it would be worth to provide a
comparison of how my code (not too trivial, and not too complex) would look
in either case. For instance:
With C++11 lambdas:
for_each( vec.begin(), vec.end(), []( std::string & n ){ if(n.empty()) n =
"n/a";} );
With Boost.Lambda + Boost.Bind:
for_each( vec.begin(), vec.end(), if_then(boost::bind(&std::string::empty,
_1), _1 = "n/a") );
With Phoenix:
using boost::phoenix::arg_names::arg1;
using boost::phoenix::if_;
using boost::phoenix::bind; // right?
for_each( vec.begin(), vec.end(), if_(bind(&std::string::empty, arg1)) [
arg1 = "n/a" ] );
With Boost.Local (Boost.Closure):
BOOST_CLOSURE_PARAMS( std::string & n ) {
if( n.empty() ) n = "n/a";
}BOOST_CLOSURE_NAME(replace_empties);
for_each( vec.begin(), vec.end(), replace_empties );
Ok, I am not sure if there are no better ways to write it in each variant,
and I may be biased. I also didn't try to compile the examples. But it
should give the potential users an overview of options they have.
Regards,
&rzej
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk