Re: [sigc] TypeLists!!!



Am 11.06.2004 19:46:02 schrieb(en) "Lemings, Eric B.":

> -----Original Message-----
> From: Martin Schulze [mailto:martin-ml hippogriff de]
> Sent: Friday, June 11, 2004 11:20 AM
> To: Lemings, Eric B.
> Cc: libsigc++ list
> Subject: Re: [sigc] TypeLists!!!
>
>
> Am 11.06.2004 19:01:33 schrieb(en) "Lemings, Eric B.":
> >
> > All template parameters lists in the API similar to this:
> >
> >   template
> >   <
> >     class T_type1,
> >     class T_type2,
> >     ...
> >   >
> >
> > can be replace with one template parameter:
> >
> >   template
> >   <
> >     typename TList
> >   >
>
> In public API? Wouldn't this mean that you needed to add an
> additional
> keyword to your signal / slot declaration like e.g.:
>
>   sigc::signal<TList<void,int> > sig1;
>
> instead of:
>
>   sigc::signal<void,int> sig1;

Yes, the TYPELIST_N macro.  E.g.,

    sigc::signal<TYPELIST_2(void, int)> sig1;


Well, IMO this is not acceptable! We have to provide a simple API for the 90% users who wouldn't benefit from typelists. Of course this could be achieved by providing both the current syntax and the typelist syntax, but then, where would we spare any code? (And who would be willing to volunteer to stem that effort? :) )

> IMHO, there is something horribly wrong in your app if you need >5
> arguments to a function.

Maybe so.  However, such apps do exist.  The Typelist.h header
supports
up to 50 parameters!

> This is the reason why using typelists might be desirable.
> However, I'm
> afraid the remaining templates would become even harder to read ...
>
> If it has no other advantage on the public API side apart from being

> able to specify >7 arguments I'm not in favour of using typelists.

Using typelists in Libsigc++ is just a suggestion.

Suggestions are always welcome! Maybe for some reason in future we will change our opinion. However, IMO, more flexibility on the implementation side cannot overweigh disadvantages on the public API side.

But consider this:
typelists were created specifically for this type of problem.  Also,
there are many list-like operations that can be performed on typelists
that cannot be performed on template parameter lists with a fixed
number of arguments.  IMHO, the benefits outweigh the drawbacks.
Hence,
the suggestion.

Read the Alexandrescu's chapter in his book before writing them off as
a bad idea.

I don't doubt the theoretical beauty of the idea. But since libsigc++ is a library you need to show us how programs using it would benefit from this technique! (Apart from the possibility of supporting >7 arguments ...)

Regards,

 Martin



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]