[proto] comments on documentation #2

Hi! <anecdote> This morning (6:45 CET) I was sitting at the breakfast table and was reading the printed PDF of proto docs. My little son (6 years old) entered the scene and the first question he asked was: "What kind of puzzle are you trying to solve?". Kids always have a keen sense of what's really going on ... </anecdote> Before I start nagging, I should say that a large subset of the docs are well-done, near perfect. The setup of the first chapters makes it easy to approach proto. But I got lost in the middle with transforms and that is a BadThing (TM), because those are the beasts everybody needs in order to get the maximum out of proto. The transform chapter leaves me with the same feeling I had 1998, 2 weeks after my decision to learn C++, when I was reading Stroustrup's TCPPL chapter about templates. I wish Vandevoorde/Josuttis would have written their book _before_ I had to use templates (and gcc). Same here: I beg for some step-by-step-by-example introduction right now. Nothing of this part of the docs reached my heart and mind. Without tiny little examples I am totally lost here. This serves well as reference documentation, but not as main entry point to a feature of a library. I will try to work through the examples now, but any introductory material appreciated here. Keep me informed about updates in that section, please. Minor issues: First of all: Expression Extensions can go a long way without transforms. So I would recommend to put this chapter in front of the one about transforms. Then introduce transforms later for those with the sword of metaprogramming knowledge and the will to survive. extends<> is useful even without transforms and so why not give it a chance before readers are drawn away by the more advanced, but horrible-to-catch features. Also it might make sense to show an example which uses std::algorithms like the original std::transform example in order to show the power of proto here. AFAICS _make_terminal drops in from heaven without introduction - right? Do we need that one? is terminal<>::type not equivalent? if yes, remove _make_terminal. ------------------------------------- The decltype stuff distracts from the key points. Unaware readers get into panik when seeing static references to types and a keyword yet not in C++. How about typedef ...implementation defined ... result_type; Then move the decltype stuff to the comment paragraph below the code as extra information. Also: why ::result_type and not ::type? Is this consistent with mpl? ----------- Could you provide a full (compilable) example for increment_ints? That would help education (though I feel like I got that one) Maybe even extend the example to an initialization action based on operator new ... ----------- sed -es,no temporaries!,no temporary vectors!,g Maybe state that there are no temporary vectors, but of course the integer 2 in stored as temporary in [2]. Also state that every modern compiler since intel's 8.1 is capable of optimizing that one away, so nobody should care, and then: Look ma! no template code on-board after optimization -> the abstraction penalty is zero! ----------------------------------------------------------- Now it is time to share some time with the kids. Read you later in this group ... Markus

Markus Werle wrote:
Before I start nagging, I should say that a large subset of the docs are well-done, near perfect. The setup of the first chapters makes it easy to approach proto.
Thanks.
But I got lost in the middle with transforms and that is a BadThing (TM), because those are the beasts everybody needs in order to get the maximum out of proto.
Transforms are certainly the hardest-to-grok part of Proto. They're also the newest part of Proto. The docs here could certainly be better.
The transform chapter leaves me with the same feeling I had 1998, 2 weeks after my decision to learn C++, when I was reading Stroustrup's TCPPL chapter about templates. I wish Vandevoorde/Josuttis would have written their book _before_ I had to use templates (and gcc). Same here: I beg for some step-by-step-by-example introduction right now.
This section needs some motivating examples. <snip>
Minor issues:
First of all: Expression Extensions can go a long way without transforms. So I would recommend to put this chapter in front of the one about transforms. Then introduce transforms later for those with the sword of metaprogramming knowledge and the will to survive.
A good suggestion.
Also it might make sense to show an example which uses std::algorithms like the original std::transform example in order to show the power of proto here.
Now that I have a Lambda example, I should reference it from the Expression Extension section.
AFAICS _make_terminal drops in from heaven without introduction - right? Do we need that one? is terminal<>::type not equivalent? if yes, remove _make_terminal.
We need std::make_pair(), strictly speaking, but it's convenient. Same for _make_terminal. It's a typedef for functional::make_expr<tag::terminal> -- handy when writing transforms. If you object to my dropping it in here without describing it anywhere, that's a fair objection.
The decltype stuff distracts from the key points. Unaware readers get into panik when seeing static references to types and a keyword yet not in C++.
<snip> Agreed.
Also: why ::result_type and not ::type? Is this consistent with mpl?
It's a TR1 function object, not an MPL metafunction.
Could you provide a full (compilable) example for increment_ints? That would help education (though I feel like I got that one)
Sure.
Maybe even extend the example to an initialization action based on operator new ...
I don't follow.
sed -es,no temporaries!,no temporary vectors!,g
Maybe state that there are no temporary vectors, but of course the integer 2 in stored as temporary in [2]. Also state that every modern compiler since intel's 8.1 is capable of optimizing that one away, so nobody should care, and then: Look ma! no template code on-board after optimization -> the abstraction penalty is zero!
Right! -- Eric Niebler Boost Consulting www.boost-consulting.com

Eric Niebler wrote:
Now that I have a Lambda example, I should reference it from the Expression Extension section.
Btw.: Did I overlook the lambda example in http://boost-sandbox.sourceforge.net/libs/proto or is it only in the svn? Markus

Markus Werle wrote:
Eric Niebler wrote:
Now that I have a Lambda example, I should reference it from the Expression Extension section.
Btw.: Did I overlook the lambda example in http://boost-sandbox.sourceforge.net/libs/proto or is it only in the svn?
It's there: http://boost-sandbox.sourceforge.net/libs/proto/doc/html/boost_proto/users_g... -- Eric Niebler Boost Consulting www.boost-consulting.com

Eric Niebler wrote:
Markus Werle wrote: [...]
Maybe even extend the example to an initialization action based on operator new ...
I don't follow.
Something along the line double * d1, d2, d3, d4; (make_expr(d1), d2, d3, d4).allocate_memory(200); being equivalent to double * d1 = new double[200]; double * d2 = new double[200]; etc. ... Or use std::vector<double> as terminals and trigger a resize for all terminals ...
participants (2)
-
Eric Niebler
-
Markus Werle