Boost logo

Boost :

From: E. Gladyshev (eegg_at_[hidden])
Date: 2004-11-16 02:10:50


Doug Gregor wrote:
>
> On Nov 13, 2004, at 3:12 AM, E. Gladyshev wrote:
>
>> Doug Gregor wrote:
>>
>>> As always, please remember to clearly state whether you believe the
>>> library should be accepted into Boost.
>>
>>
>> The library is a good start but I don't think that
>> it should be accepted w/o a native support for
>> named parameters functors. The macros are not good enough.
>>
>> Eugene
>
>
> You are referring to a facility such as the one you documented here?
>
> http://tinytl.sourceforge.net/#func_named_params_function

Yes, I just call it named parameters functors.

>
> Could you say why you find this feature so important that the library
> should be rejected due to the lack of the feature? What concerns does
> this feature address that the existing interface does not?

Well, let me rephrase,
I think that the library should not
be accepted without at least
*considering* named parameters functors.

Some of the reasons are:

1. I think that one of the important
applications of the library is creating
named parameters wrapper around legacy
C interfaces with a bunch of parameters.
It seems to me that named parameters functors
are an elegant way to do it without macros.
I personally belong to a large group
of developers who don't favor macros unless there are
really necessary. Please I don't mean to
get into a discussion about macros in general.

2. Most imporantly, named parameters
functors extend the library ideas to
function objects (function pointers)
in general. For instance you can easily
declare a named parameter "pointer"
and assign different implementations to it.
Perhaps it would be even possible
to make named parameters functors work
with stuff like signals, etc.

Here is an example with class members.
I think that it is much more fun
than macros. :)

struct widget
{
     //define a named parameters functor
     typedef ttl::func::named_params_function<
         int //the function returns 'int'
         (
             //'argument name', 'argument type'
               title, const char*
             , style, ttl::func::numeric_argument<int, 45>
//the default is 45
         )
> create_functor;

     //
     widget()
     {
         //initialize the functor with create_impl
         create = boost::bind( &widget::create_impl, this, _1, _2 );
     }

     create_functor create;

private:
     int create_impl( const char* title, int style );
};

main()
{
     widget w;

     w.create( w.create.arg<title>("my widget") );

     return 0;

}

Eugene


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