Re: Formal Review: FOREACH macro

* What is your evaluation of the design? Very good. It's very easy to use and the support for lvalues access to container/range elements is very powerful and convenient. Also when using overloaded operators on the elements, the resulting code is much cleaner with FOREACH than with an iterator based loop. * What is your evaluation of the implementation? Brilliant * What is your evaluation of the documentation? Good. The library doesn't need too much documentation really. Maybe some pitfall section as already has been mentioned would be a useful addition. * What is your evaluation of the potential usefulness of the library? Very useful - it lets you express small ad-hoc algorithms in an elegant way and in the place where you want them. I have used it for more than 6 months now and have added it to my standard set of idioms. Once you get into the FOREACH mindset, you don't only want to use it for std::for_each type jobs but you would also want to use it for std::transform type ones. In situations where you can use push_back on a result container, FOREACH serves this purpose as it is. However, I have encountered situations where this was not possible and where I wanted a second macro, say FOREACH2, that iterates over 2 ranges simultaneously. I have had such a need on more than one occasion. One situation was as above and in other situations I had to combine the elements of two ranges. I implemented such a FOREACH2 macro myself based on Eric's implementation and it appeared to be relatively straightforward. For this reason, I would like to request this as an enhancement to the library. Users of FOREACH wouldn't be affected by such an additional macro, so I see little reason why people would object to it. Similarly, I could imagine use for a 3 range version, where the elements of two ranges are combined and the results get written into the third range exactly as you can do with std::transform. * Did you try to use the library? With what compiler? Did you have any problems? As mentioned above, I have used the library on a regular basis for over 6 months. All my experience is based on using it with VC7.1. I have not had any problems. * How much effort did you put into your evaluation? A glance? A quick reading? In-depth study? 6 month experience with the library from a user perspective. After reading Eric's article on Artima, I have studied the implementation in quite a bit of detail so that I could implement an extended version that would iterate over 2 ranges. * Are you knowledgeable about the problem domain? Not more or less than other experienced C++ developers. * Do you think the library should be accepted as a Boost library? YES, definitely. Cheers, Sam Saariste

"Sam Saariste" <ss_march2001@pobox.com> writes:
I have used it for more than 6 months now and have added it to my standard set of idioms. Once you get into the FOREACH mindset, you don't only want to use it for std::for_each type jobs but you would also want to use it for std::transform type ones. In situations where you can use push_back on a result container, FOREACH serves this purpose as it is. However, I have encountered situations where this was not possible and where I wanted a second macro, say FOREACH2, that iterates over 2 ranges simultaneously. I have had such a need on more than one occasion. One situation was as above and in other situations I had to combine the elements of two ranges.
Try using zip_iterator with BOOST_FOREACH. -- Dave Abrahams Boost Consulting www.boost-consulting.com
participants (2)
-
David Abrahams
-
Sam Saariste