Template mixins: Why is the decision to mixin made at the call site?
div0 at users.sourceforge.net
Sat Aug 22 02:43:03 PDT 2009
-----BEGIN PGP SIGNED MESSAGE-----
Steven Schveighoffer wrote:
> On Fri, 21 Aug 2009 13:54:38 -0400, div0 <div0 at users.sourceforge.net>
>> -----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.
>> 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.
That would be nice.
You can sort of bodge that at the mo.
Just stick a const method in the template, then if you try and use it
outside a class/struct the compiler barfs.
Though really that needs to change; it's inconsistent.
My enormous talent is exceeded only by my outrageous laziness.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
-----END PGP SIGNATURE-----
More information about the Digitalmars-d-learn