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

Chad J chadjoan at __spam.is.bad__gmail.com
Thu Aug 20 18:50:23 PDT 2009


Regarding template mixins, I'm curious, why is the decision to mixin a
template made at the call site and not at the declaration of the
template/mixin?

In other words, why do we write

	template foo()
	{
		// etc..
	}

	mixin foo!();

instead of

	mixin foo()
	{
		// etc..
	}

	foo!();

??

It seems to me like in most cases you determine whether or not you want
to mixin based on the contents of the template, not based on the the
calling code.  Not to mention, declaring as a mixin would allow us to
omit that mixin keyword anytime we want to do something cool with
template mixins.  So it seems odd to me as I reflect on it.


More information about the Digitalmars-d-learn mailing list