Boost logo

Boost :

From: Andy Little (andy_at_[hidden])
Date: 2005-06-14 19:25:31


"John Maddock" wrote
> The Formal Review of the Function Types Library begins today, and runs until
> 16th June 2005.

> What is your evaluation of the design?

Not being a target everyday user of this library I wouldnt like to make too much
comment.. OTOH ... here goes ;-)

Is there a proposed use for these tags? I'm interested in the reason for use of
these tags over separate functions.
eg
instead of ..

    template<typename Tag, typename T>
    struct is_function_type;

Why not :

is_any_function<F>
is_variadic_function<f>

etc

OTOH why not do it the other way round eg

    template<typename F, typename Tag = any_function>
    struct is_function_type;

eg giving is_function_type<F> for what I guess is the most usual case.

I know this overlaps type_traits, but therefore is this any_function necessary?

Does providing non functions-types to eg function_type_arity<F> give a compile
time assertion? Cos I think it should!

> What is your evaluation of the implementation?

I havent looked at the implementation.

> What is your evaluation of the documentation?

I would really like an accessible example right at the start.
What is this library useful for? The example source files seem to have little
regard for anyone reading them.

The closure example looks interesting (though I'm not sure what a closure is)but
perhaps this could be the basis of an in depth example followed through in the
documentation. There are few comments in the examples and in a lot of cases
they just look like test programs.

I'd especially like to see an example of application to callbacks.
eg (Apologies I may be rambling, but I'm trying to find simple useage scenarios
in the following. Of course standard library examples would be better))

Say I needed a list of actions on a list with varying arguments:
I could make some Functors:

// Abstract Base Class
template<typename List>
struct Action {
    virtual List & operator() (List & in)=0; // do something to a list
};

// some actions -- sort
template<typename List>
struct MySort : Action<List>{
    typedef typename List::value_type value_type;
    typedef bool (*pf) (value_type const & , value_type const &);
    MySort (pf pf_in); // construct with required function
    List & operator() (List & in);
};

// remove on predicate
template<typename List>
struct RemoveIf : Action<List>{
    typedef typename List::value_type value_type;
    typedef bool (*pf) (value_type const & );
    RemoveIf (pf pf_in); // construct with required function
    List & operator() (List & in);
};

But presumably I could replace these two derived classes by suitable use of
function_traits

template<typename List, typename FunctionType>
struct MyAction : Action<List>{
    typedef typename List::value_type value_type;
    typedef typename Unwrap<FunctionType>::type function;
    function f;
    List & operator()(List & in)const
    { // some generic mechanism to invoke on varying args
        invoke<FunctionType>(in,typename FunctionType::ArgType(f) );
    }
    MyAction(function in): f(in);
};
Unwrap is some magic to create the function pointer from its varying parts
Wrap is some magic to construct the FunctionType from an input function type;

The above may or may not make sense...
Whatever there must be some more Simple useage examples.
IOW how is this library useful with callbacks and/or synthesis of functions?

> What is your evaluation of the potential usefulness of the library?

I think its up to the author to show me with better simpler examples, showing
this.

> Did you try to use the library? With what compiler? Did you have any
> problems?

I tried a couple of simple examples in VC7.1. No problems.

> How much effort did you put into your evaluation? A glance? A quick reading?
> In-depth study?

A couple of hours thinking and reading.

> Are you knowledgeable about the problem domain?

No.

> And finally, every review should answer this question:
>
> Do you think the library should be accepted as a Boost library? Be sure to
> say

I abstain. If its useful in implementing all the libraries it says it can then
it must be very useful, but I'm afraid that the author must take more trouble
with explaining things to simpler souls like myself in my opinion.

regards
Andy Little


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