Summary: Mixin template evaluated to string can convert to
                    string mixin expression implicitly
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: DMD

--- Comment #0 from Kenji Hara <> 2011-06-24 03:48:28 PDT ---
If mixin template instantiation makes manifest constant string and it appears
in expression context, the compiler converts it implicitly to string mixin

This enhancement feature does not conflict with any existing features.
Because normal instantiating with mixin template is illegal.

Sample code:
mixin template expand(string code)
    static if (code.length >= 2 && code[0..2] == "$x")
        enum expand = `x` ~ code[2..$];
        pragma(msg, expand);
        enum expand = code;

void main()
    int x = 1;
    int y = expand!q{$x+2};
        // Rhs is implicitly converted to mixin(expand!(q{$x+2}))
    assert(y == 3);

Configure issuemail:
------- You are receiving this mail because: -------

Reply via email to