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

div0 div0 at users.sourceforge.net
Fri Aug 21 10:36:39 PDT 2009


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Chad J wrote:
> 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.

Not sure what the original choice was based on, but what you suggest
looks wrong to me. You aren't necessarily using a template in order to
mix it in somewhere.

With that syntax it looks like you can only use foo as a mixin. If you
change 'mixin' to 'paste' your way round looks even more wrong.

- --
My enormous talent is exceeded only by my outrageous laziness.
http://www.ssTk.co.uk
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iD8DBQFKjtsnT9LetA9XoXwRAipLAJ92/vE9Ofmb0sJpOqoqIYyctT6MNgCgl0IH
MdLpTZ582D7iJ9j06dcTpa4=
=5yW1
-----END PGP SIGNATURE-----


More information about the Digitalmars-d-learn mailing list