Template mixins: Why is the decision to mixin made at the call site?

Steven Schveighoffer schveiguy at yahoo.com
Fri Aug 21 14:07:35 PDT 2009


On Fri, 21 Aug 2009 13:54:38 -0400, div0 <div0 at users.sourceforge.net>  
wrote:

> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Jarrett Billingsley wrote:
>> On Fri, Aug 21, 2009 at 1:36 PM, div0<div0 at users.sourceforge.net> wrote:
>>
>> That's what he's suggesting, and it does make sense.  When you write a
>> template, *either* it's meant to be used as a mixin, *or* it's meant
>> to be used some other way.  Mixin in a template that wasn't meant to
>> be a mixin or vice versa usually makes no sense.
>
> Hmmm.
>
> Not convinced by that argument, I can think of good reasons to use a
> template as both.
>

What you could have is similar to scope classes, that is, if you define a  
template as a mixin template, it's always meant to be a mixin (which is a  
common case).

Now, scope classes must be declared as scope when used, so does it make  
sense to require mixin templates to be called via mixin?  I'm not sure, it  
would be against what the O.P. desired, but seeing the mixin keyword at  
the usage site is a huge documentation hint.

I do see value in declaring a template as a mixin template, making it an  
error to use it as a normal template.

-Steve


More information about the Digitalmars-d-learn mailing list