[Issue 3437] New: No way to make conversions to string in pure functions.

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Oct 22 17:30:13 PDT 2009


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

           Summary: No way to make conversions to string in pure
                    functions.
           Product: D
           Version: 2.035
          Platform: Other
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody at puremagic.com
        ReportedBy: alvcastro at yahoo.es


--- Comment #0 from Alvaro <alvcastro at yahoo.es> 2009-10-22 17:30:11 PDT ---
This code can't compile:

{{{

import std.conv;                                                                

pure string genCode(int num) {
    string result = "auto a = " ~ to!(string)(num) ~ ";";
    return result;
}

void main() {
    mixin( genCode(1) );    
}


}}}


If you want to generate the body of a pure function with any numerical
parameter from outside, there is no way to do it.

toStringNow! doesn't help here either.

Purity should be checked after the CTFE functions have been executed.

-- 
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