Games people play

Josh Stern josh_usenet at phadd.net
Tue Oct 3 22:57:12 PDT 2006


On Tue, 03 Oct 2006 22:04:03 -0700, Walter Bright wrote:

> Bill Baxter wrote:
>> Yes.  For statically checked S&S, templates & mixins seem like they 
>> provide basically all that is needed to implement a good solution, 
>> (maybe there's still some weak reference business that needs to be 
>> sorted out, but it looks like it's mostly there).  The main wart is that 
>> you have to have a different template for each number of arguments, 
>> resulting in repetitive code.  Some form of Variadic Templates would be 
>> very nice to have there.
>> 
>> So instead of
>> template Signal(T1) // for one argument ...
>> template Signal(T1, T2) // for two arguments ...
>> template Signal(T1, T2, T3) // for three arguments ...
>> template Signal(T1, T2, T3, T4) // for four arguments ...
>> template Signal(T1, T2, T3, T4, T5) // for five arguments ...
>> template Signal(T1, T2, T3, T4, T5, T6) // for six arguments ...
>> template Signal(etc...
>> 
>> You can just have one template
>> template Signal(...) // for any number of arguments ...
> 
> That would be better, but the user doesn't see that code, just the 
> library implementer. So it isn't so bad.

Agreed, not a significant issue issue in this case, though the variadic
feature might have saved the library writer (or future application
authors) some time and cut down on some parsing overhead.

>> But something more is needed for Dynamic Qt-like S&S.  Some sort of 
>> compile-time introspection seems a minimal requirement.  I think some 
>> way to tag particular method like Qt's "slot:" keyword will also be 
>> necessary to make it usable.  Anyway you need some way to say "do 
>> something with this method" and do it at the point of declaration rather 
>> than in the constructor or elsewhere.
> 
> I don't understand. Exactly what needs to be done at compile time that 
> can't be done with the mixin method?

It would be nicer to implement S&S without the need for modifying source
code of existing classes or adding overhead to all uses of those classes.










More information about the Digitalmars-d mailing list