Boost logo

Boost :

Subject: Re: [boost] Request for review: Boost.Fit
From: Paul Fultz II (pfultz2_at_[hidden])
Date: 2015-09-29 11:42:55


On Monday, September 28, 2015 at 3:35:37 PM UTC-5, Edward Diener wrote:
>
> On 9/28/2015 10:45 AM, paul Fultz wrote:
> > Hi All,
> >
> > Boost.Fit is a header-only function utility library for C++11. It
> supports
> > both gcc, clang and visual studio. More info can be found here:
> >
> > https://github.com/pfultz2/Fit
> >
> > I would like to take this time to ask for a review. Vicente Botet has
> > mentioned he could be a review manager. So I would like to move forward
> in
> > scheduling a formal review. I plan to boostify the library for the
> formal
> > review. In addition, I would like to ask for an informal review at this
> time.
> > If anyone has some feedback or questions, that would be greatly
> appreciated.
>
> Would I be right in saying that Fit's library functionality is based on
> creating global variables which represent function objects ?

It does provide a lot of capabilities for this, but it is not limited to
this.
 

> If so this
> seems a negative for me as I try, like many other C++ programmers, to
> avoid using global variables in my modules.

It is considered bad to share global state in the program, which is why
global mutable variables and shared pointers is not recommended. However,
it is not considered bad practice to define gloabl consts in the program(in
fact it is recommended over magic numbers), which is what these global
function objects are. Furthermore, this is common practice in a lot of
libraries, such as Boost.Spirit, Boost.Proto, Boost.Phoenix, Boost.Hana and
ranges-v3.
 

> OTOH if Fit can work with
> function objects which are member variables or local variables its
> usefulness would be much greater IMO.
>

Yes, the adaptors can work with any function object(local or global). It
just requires a little more boilerplate to wrap it in a function for global
consumption. For example, you can write the print function in the quick
start guide as a function as well:

template<class T>
void print(const T& elem)
{
    fit::conditional(
        fit::if_(std::is_fundamental<T>())([](auto& x) { std::cout << x <<
std::endl; });
        [](const std::string& x) { std::cout << x << std::endl; },
        [](auto& range) { for(const auto& x:range) print(x); }
    )(elem);
}
 

>
>
>
> _______________________________________________
> Unsubscribe & other changes:
> http://lists.boost.org/mailman/listinfo.cgi/boost
>


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