
Markus Werle wrote:
Hi!
[@Eric: The docs look much greater now. Thank you for the hard work. As I can afford time I will go through the docs step by step, give comments again and ask silly questions like before. Is it OK for You that this happens on the public ML? IMHO this may help others, too. Some remarks are rather nitpicking stuff, but still considered to be helpful for first time users of proto]
Here is fine. Thanks for taking the time to offer feedback.
In this post I refer to <http://boost-sandbox.sourceforge.net/libs/proto/doc/html/ boost_proto/users_guide/getting_started/hello_calculator.html>
Q1: Probably a typo: Is it "Customing" or "Customizing"?
Thanks.
Q2: It is not clear to me why operator() has 3 arguments:
double operator()(double a1 = 0, double a2 = 0, double a3 = 0) const { calculator_context ctx; ctx.args.push_back(a1); ctx.args.push_back(a2); ctx.args.push_back(a3);
return proto::eval(*this, ctx); }
IMHO the whole thing should work even without the 3rd argument. Can you explain?
I've only shown placeholders _1 and _2, so you're right, the third argument will never be used. I'll remove it.
R1: For didactic reasons I would add examples that do not rely on the assumption that the user knows STL by heart, e.g. immediately before
<cite> // Use std::transform() and a calculator expression // to calculate percentages given two input sequences: std::transform(a1, a1+4, a2, a3, (_2 - _1) / _2 * 100); </cite>
please add the following code:
double const result = ((_2 - _1) / _2 * 100)(45.0, 50.0); BOOST_ASSERT(result == (50.0 - 45.0) / 50.0 * 100)); // is this portable?
This proposal is in analogy to the code presented in the boost::bind docs at http://www.boost.org/doc/libs/1_36_0/libs/bind/bind.html, which I always found _very_ helpful, since they separate one thing from another.
Good suggestion.
R2: In "Controlling Operator Overloads" it would help a lot if the difference between the previous approach and the new approach was written in *bold*, in order to hinder a scroll
proto::domain< proto::generator<calculator>, <BOLD>calculator_grammar</BOLD> >
or like this:
struct calculator_domain // OLD version had default grammar //: proto::domain< proto::generator<calculator> > : proto::domain< proto::generator<calculator>, calculator_grammar > {};
OK, will do. -- Eric Niebler BoostPro Computing http://www.boostpro.com