Boost logo

Boost :

Subject: [boost] Rave for proposed Boost.Local (functions)
From: Gregory Crosswhite (gcross_at_[hidden])
Date: 2011-02-01 18:04:42


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!

At first I thought that the interface needed to use it was ugly, but as
I have gotten used to it I have changed my mind. Part of why I thought
it was ugly was because of the way that whitespace was used in the
example included in the original e-mail:

         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);

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);

I would be happy to volunteer to be the review manager if one is needed
to move the process along, but since I am new to the community and
personally biased in favor of the library (though I would endeavor to be
unbiased as a reviewer) I recognize you all will presumably want someone
that you all know better and who is more neutral. Regardless, I hope
that we can start down the road of incorporating this library into boost
because I believe it would be of great benefit to the C++ community at
large.

Cheers,
Greg


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk