internal/local template memebers

Bill Baxter wbaxter at gmail.com
Sat Oct 25 11:54:45 PDT 2008


On Sat, Oct 25, 2008 at 10:34 PM, Denis Koroskin <2korden at gmail.com> wrote:
> On Sat, 25 Oct 2008 17:08:28 +0400, Bill Baxter <wbaxter at gmail.com> wrote:
>
>> On Sat, Oct 25, 2008 at 8:48 PM, Denis Koroskin <2korden at gmail.com> wrote:
>>>
>>> On Sat, 25 Oct 2008 08:05:41 +0400, BCS <ao at pathlink.com> wrote:
>>>
> This is because you usual templates and mixin templates are completely
> different, mixin'ing usual template or instantiating template that is
> intended for being mixed-in makes no sense in the majority of real cases.

Good point.  I can't think of any case where something I've written as
a mixin would be useful as a stand-alone template.
I usually end up calling my mixin templates something with "Mix" in the name.

But it does seem like it would be tricky for the compiler to determine
which case you meant.   Unless you told it which case... which is
exactly what you suggest next.

> Moreover, I would prefer to separate these terms and so their syntax:
>
> mixin template Bar

That sounds quite reasonable to me.  (Though it's 4am and I just woke
up, so I may not be at my peak right now)
I would also appreciate templates being distict from mixin templates
too.  If you actually did run into some need for a template that can
be either, then just mixin the mixin into a template!

mixin template BarMix(T)
{
   ...
}
template Bar(T)
{
    mixin BarMix!(T);
}

--bb



More information about the Digitalmars-d mailing list