[Issue 10485] can not distinguish method call in string mixin!

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Jun 27 06:49:55 PDT 2013


http://d.puremagic.com/issues/show_bug.cgi?id=10485


Andrej Mitrovic <andrej.mitrovich at gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |andrej.mitrovich at gmail.com
         Resolution|                            |INVALID


--- Comment #2 from Andrej Mitrovic <andrej.mitrovich at gmail.com> 2013-06-27 06:49:54 PDT ---
Templates can only be used to create declarations, not expressions. One
workaround is to write the code like the following:

-----
import std.stdio;

class TestClass
{
    void call()
    {
        writeln("called");
    }
}

mixin template test(string name)
{
    struct S
    {
        void call()
        {
            scope tc = new TestClass;
            tc.call();
        }
    }

    mixin("S " ~ name ~ ";");
}

void main(){
    mixin test!("var");
    var.call();
}
-----

But note that 'scope' is a feature that will eventually be deprecated.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list