
Gregory Crosswhite wrote:
Hey everyone,
The purpose of this e-mail is to rave about Lorenzo's proposed Boost.Local library in the hopes of inspiring people to start the review process for it. :-)
I have been experimenting with using this library in my own code, and it has been a godsend for me. In one of the projects I have been working on I ran into many situations where I needed to call a higher-order function with a closure, and the closure was just complicated enough that I couldn't use Boost.Lambda. Before using this library I frequently found myself either writing a lot of extra code to work-around the need for a higher-order function, or writing a lot of boilerplate to create classes that would only be used by a single function in order to create a function object. This library has let me write the closures that I need in a fairly painless fashion and so has made my life a lot easier!
I would be interested in what limitations you ran into using Boost.Lambda and if you are aware of the recent efforts that were put into Boost.Phoenix?
To my mind this example looks a lot clearer if you reformat it as follows:
BOOST_LOCAL_FUNCTION( (void) (add)( (double)(num) (const bind)((factor)) (bind)((&sum)) ) ) { sum += factor * num; std::clog<< "Summed: "<< sum<< std::endl; } BOOST_LOCAL_FUNCTION_END(add) add(100.0);
As far is a am concerned, I still find this syntax overly verbose. I do realize though that this is just a toy example. For better comparison, Here is how the same thing would like in Boost.Phoenix: boost::function<void(double)> add =( ref(sum) += factor * _1, std::clog << var("Summed: ") << sum << std::endl ) ; add(100.0); Despite the Local Blocks and Local Exits feature, I can't see much difference to the already existing lambda libraries. I just looked through the Boost.Local documentation and immediately navigated to the "Alternatives" section and its not really correct regarding the features of Boost.Lambda and Boost.Phoenix. I am specifically talking about the "Bind variables in scope" and "Program body using usual C++ syntax" part. The last is debatable, but how are the above examples (both of Boost.Local and Boost.Phoenix) not C++ syntax? Can you highlight the advantages/disadvantages again?
Cheers, Greg _______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost