On Mon, 15 Feb 2010 02:28:38 +0300, Andrei Alexandrescu
<[email protected]> wrote:
Denis Koroskin wrote:
On Mon, 15 Feb 2010 00:31:29 +0300, Walter Bright
<[email protected]> wrote:
Right now, mixins are defined and used as:
template foo(T) { declarations... }
mixin foo!(int) handle;
The proposal is to switch it around:
mixin template foo(T) { declarations... }
foo!(int) handle;
to follow the notion that mixin templates are very different from
regular templates, and that should be reflected in their definition
rather than use.
What do you think?
I support the change, expect that I believe mixing in the mixin
template should involve the "mixin" keyword.
[snip previous proposal]
The hope with the proposed change is to leverage existing mixin
implementation into a solid and useful facility that could actually
obviate the need for macros. I reckon there is a lot of value in the
current mixin template idea, but it's just packaged the wrong way.
Requiring mixin on the call side (something that many have complained
about) would, in my opinion, keep the feature packaged the wrong way.
As an example of where we want to take this, consider an interpolation
facility. The expression:
interp!"a = $a and b = $b\n"
expands into:
"a = ", a, " and b = ", b, "\n"
which you can writeln, pass to text or whatnot.
Andrei
Point taken. I agree this makes code look cleaner.