$include_dir="/home/hyper-archives/boost/include"; include("$include_dir/msg-header.inc") ?>
Subject: Re: [boost] [Fit] formal review starts today
From: Paul Fultz II (pfultz2_at_[hidden])
Date: 2016-03-07 22:02:43
On Monday, March 7, 2016 at 2:52:09 AM UTC-6, Edward Diener wrote:
>
> On 3/7/2016 12:15 AM, Paul Fultz II wrote: 
> > 
> > 
> > On Sunday, March 6, 2016 at 9:42:19 PM UTC-6, Edward Diener wrote: 
> >> 
> >> On 3/3/2016 6:43 AM, Vicente J. Botet Escriba wrote: 
> >>> Dear Boost community, sorry for the late anounce 
> >>> 
> >>> The formal review of Paul Fultz II's Fit library starts today, 2nd 
> March 
> >>> and ends on 13th March. 
> >>> 
> >>> Fit is a header-only C++11/C++14 library that provides utilities for 
> >>> functions and function objects. 
> >> 
> >> These are some comments/queries about the Fit documentation. 
> >> 
> >> Introduction 
> >> 
> >> The introduction says that Fit "provides utilities for functions and 
> >> function objects." But it seems as if Fit works only with lambda 
> >> functions and function objects. 
> > 
> > 
> > Fit works with any generalized Callable: 
> > 
> > http://en.cppreference.com/w/cpp/concept/Callable 
>
> Please document this. A generalized Callable is a much bigger set of 
> functionality than just lambda functions and function objects. 
>
> > 
> > 
> >> The term 'function' normally encompasses 
> >> a much larger definition in C++ which includes global functions, static 
> >> functions, member functions, and lambda functions. 
> > 
> > 
> > Which is what Callable encompasses, but I used "function" since more 
> > people are familiar with that than Callable. 
>
> A 'function' and a Callable in C++ are two entirely different things. 
> Use the one that is precise and don't worry what people are familiar 
> with. Explain what a Callable is early on ( I know you explain it later 
> ) if you feel that people do not know what it means. 
>
> > 
> > 
> >> Fit needs to be more 
> >> precise in what it says it works with. It repeatedly refers to function 
> >> objects and lambda functions as 'functions'. I think this vagueness of 
> >> terminality is really confusing in the documentation. 
> >> 
> > 
> > Perhaps, I should refer to the Callable concept early on then. 
>
> See above. 
>
> > 
> > 
> >> 
> >> Quick Start:Function Objects 
> >> 
> >> "We can make it behave like a regular function if we construct the 
> class 
> >> as a global variable." 
> >> 
> >> What about a non-global 
> >> 
> >> sum_f sum = sum_f(); 
> >> 
> >> makes 'sum' not behave like a regular function other than the fact that 
> >> the variable 'sum' may eventually go out of scope ? 
> >> 
> > 
> > In C++, a regular function is always global, there is no such thing as 
> local 
> > function(sans gcc extensions). 
>
> My point is that the non-global 'sum' in my example above behaves just 
> as much like a regular function as your global 'sum'. You may want to 
> promote the idea of global function objects but I think that this is 
> personally a bad idea. IMO global variables of any kind are to be avoided.
 
It is quite common in several modern C++ libraries to declare functions as
global objects. There are many advantages to this. Why do you believe it
should be avoided? Especially since it has the same effect as a free 
function.
DO you believe free function should be avoided as well?
 
>
>
> > 
> > 
> >> 
> >> Quick Start:Lambdas 
> >> 
> >> Why do we need both BOOST_FIT_STATIC_LAMBDA and 
> >> BOOST_FIT_STATIC_LAMBDA_FUNCTION ? I would seem that 
> >> BOOST_FIT_STATIC_LAMBDA_FUNCTION would be adequate and 
> >> BOOST_FIT_STATIC_LAMBDA is just redundant, mimicking lambda syntax to 
> no 
> >> purpose. 
> >> 
> > 
> > BOOST_FIT_STATIC_LAMBDA_FUNCTION and BOOST_FIT_STATIC_FUNCTION both 
> define a 
> > function at global scope, and can only be used at global scope, whereas 
> > BOOST_FIT_STATIC_LAMBDA can be used to constexpr initialize local 
> variables 
> > as 
> > well. 
>
> It might be good to add that when the end-user first encounters 
> BOOST_FIT_STATIC_LAMBDA, because the name does not suggest 
> initialization of local objects. Furthermore I cannot imagine why one 
> would want to use it to initialize a local object, 
Really? You just said that you would prefer avoiding global functions.
 
> so you might want to 
> explain the benefit of doing so as opposed to the normal syntax for 
> creating a lambda function. 
>
Maybe the quick start guide isn't the place for this in the first place.
 
>
> > In fact, BOOST_FIT_LIFT uses this since it is not always clear what 
> > context the user might call BOOST_FIT_LIFT. 
> > 
> > 
> >> 
> >> Quick Start:Overloading 
> >> 
> >> The overloading adaptors show two or more lambda functions. Can they 
> >> also work with function objects ? Or a mix of lambda functions and 
> >> function objects ? In fact all the reamining Quick Start topics show 
> >> examples with lambda functions. Do they also work with function objects 
> ? 
> >> 
> > 
> > Yes it can be used with function objects. I probably should show an 
> example 
> > of 
> > that as well. I used the lambdas because of the terseness of them. 
>
> Evidently the adaptors can be used with any Callable. I think you should 
> make that point very strongly and show that in examples also. 
>
Agreed.
 
>
> > 
> > 
> >> 
> >> Quick Start:Variadic 
> >> 
> >> I do not understand what 'We can also make this print function 
> varidiac, 
> >> so it prints every argument passed into it.' means ? 
> >> 
> > 
> > I'll try to explain that better, but basically it will print each 
> argument, 
> > so: 
> > 
> > print("hello", 5); // Will print "hello" and 5 
>
> I wouldn't associate that with the word 'Variadic' but I do think you 
> need to explain that more clearly. 
>
I always understood variadic to mean taking a variable number of 
arguments. What do you understand variadic to mean?
 
>
> > 
> > 
> >> 
> >> I do not think the Quick Start explains very much since it is dealing 
> >> with adaptors of which we know almost nothing and the explanation for 
> >> these adaptors and what they actually do is very terse. 
> > 
> > 
> > Probably can expand the explanation of adaptors a little more. 
>
> Good idea. What do adaptors create ? 
They create a function.
 
> Different function objects I would 
> imagine ? In that case how about the explanation that adaptors take 
> Callables as input and generate function object types that adapt the 
> original functionality of one or more Callables to some other purpose. 
>
The examples are already show taking Callables. Are you suggesting I 
show an example taking a member function or something? 
> 
> > 
> >> 
> >> In the 'Signatures' section of the Overview I read: 
> >> 
> >> "All the functions are global function objects except where an explicit 
> >> template parameter is required." I honestly don't know what this is 
> >> supposed to mean. Does this refer to when function objects are referred 
> >> to as parameters to the adaptors, functions, and utilities of the 
> library 
> >> ? 
> >> 
> > 
> > I don't understand what you are asking. It means that the function is 
> > written 
> > like this in the documentation: 
> > 
> > template<class IntegralConstant> 
> > constexpr auto if_(IntegralConstant); 
> > 
> > But its actually a function object like this in the code: 
> > 
> > struct if_f 
> > { 
> >      template<class IntegralConstant> 
> >      constexpr auto operator()(IntegralConstant) const; 
> > }; 
> > const constexpr if_f if_ = {}; 
> > 
> > However, `if_c` is written like this in the documentation: 
> > 
> > template<bool B, class F> 
> > constexpr auto if_c(F); 
> > 
> > It requires the bool `B` template parameter explicity. So in the code it 
> is 
> > written as a function and not as a function object. 
>
> I don't understand to what you are referring when you say 'function'. 
> Are you talking about adaptors in your library, functions in your 
> library, or what ? 
I am talking about all functions that are defined in the library, that
includes adaptors as well. I am not sure how to make that clearer.
 
> Please try to understand that your use of the word 
> 'function' is very broad but that the word 'function' in C++ has a much 
> narrower meaning. 
>
By function, I mean something like in the example:
template<class IntegralConstant>
constexpr auto if_(IntegralConstant);
I think everyone agrees that is a function in C++.