On 2010-02-14 16:31:29 -0500, Walter Bright <[email protected]> said:

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?

There's one thing I'd wish a lot to be able to do in a template mixin: being able to get the name of the 'handle' part from inside the template. I'm wondering, if you implement this change, could you add syntax to get that? I was thinking of "mixin.stringof", and it'd be usable like this:

        mixin template Value(int) {
                int value;
                void write() { writeln("Value '", mixin.stringof, "' is ", 
value); }
        }

        class A {
                Value!int test;
        }

        A a = new A;
        a.hello.write(); // writes "Value 'test' is 0"


--
Michel Fortin
[email protected]
http://michelf.com/

Reply via email to