Thread overview
[Issue 3437] New: No way to make conversions to string in pure functions.
Oct 23, 2009
Alvaro
Feb 26, 2010
Don
Jun 13, 2011
yebblies
October 23, 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@puremagic.com
        ReportedBy: alvcastro@yahoo.es


--- Comment #0 from Alvaro <alvcastro@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: -------
February 26, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=3437


Don <clugdbug@yahoo.com.au> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |clugdbug@yahoo.com.au
          Component|DMD                         |Phobos


--- Comment #1 from Don <clugdbug@yahoo.com.au> 2010-02-26 08:14:56 PST ---
This is a Phobos issue. It's just because the to!() functions are not marked as
pure. Also the CTFE support for to!() functions is still limited.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
June 13, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=3437


yebblies <yebblies@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |yebblies@gmail.com
         Resolution|                            |DUPLICATE


--- Comment #2 from yebblies <yebblies@gmail.com> 2011-06-12 23:22:58 PDT ---
*** This issue has been marked as a duplicate of issue 4850 ***

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