Thread overview
[Issue 6471] New: std.metastrings.Format has recursive expansion problems
Aug 12, 2011
Ellery Newcomer
Aug 12, 2011
Ellery Newcomer
Jul 02, 2013
Ellery Newcomer
August 12, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=6471

           Summary: std.metastrings.Format has recursive expansion
                    problems
           Product: D
           Version: D2
          Platform: Other
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Phobos
        AssignedTo: nobody@puremagic.com
        ReportedBy: ellery-newcomer@utulsa.edu


--- Comment #0 from Ellery Newcomer <ellery-newcomer@utulsa.edu> 2011-08-11 18:35:28 PDT ---
dmd32 2.054.

compiling the attached file results in

/usr/include/d/std/metastrings.d(72): Error: template instance
std.metastrings.FormatString!("*/\x0a    @property Node right%s(Node
newNode)\x0a    {\x0a        _right%s = newNode;\x0a        if(newNode !is
null)\x0a            newNode._parent%s = &this;\x0a        return newNode;\x0a
  }\x0a",N,N,N) recursive expansion

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



--- Comment #1 from Ellery Newcomer <ellery-newcomer@utulsa.edu> 2011-08-11 18:37:07 PDT ---
Created an attachment (id=1016)
dmd doesn't like Format

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
July 01, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=6471


hsteoh@quickfur.ath.cx changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |hsteoh@quickfur.ath.cx


--- Comment #2 from hsteoh@quickfur.ath.cx 2013-07-01 12:27:28 PDT ---
Now that std.format is CTFE-able, std.metastrings has been deprecated. Maybe this bug can be closed?

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
July 02, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=6471



--- Comment #3 from Ellery Newcomer <ellery-newcomer@utulsa.edu> 2013-07-01 17:12:25 PDT ---
Depends on whether you consider it a dmd issue or a phobos issue.

I just took a second look at this and.. you get a recursion depth of exactly 500 for templates. I don't recall this restriction being documented anywhere, so if it isn't, it should be, and after that maybe take up the question of whether it is an acceptable restriction (with ctfe maybe it is now).

import std.string;
enum s = "abcdefghijklmorpshtn";
static assert(s.length == 20);
enum t = s ~ s;
static assert(t.length == 40);
enum u = t ~ t;
static assert(u.length == 80);
enum v = u ~ u;
static assert(v.length == 160);
enum w = v ~ v;
static assert(w.length == 320);
enum x = w ~ v ~ s;
static assert(x.length == 500);
/*
// ok!
enum x = w ~ v ~ s[1..$];
static assert(x.length == 499);
*/

template iter(string s, T) {
    static if(s.length == 0) {
        enum iter = "";
    }else{
        enum iter = toUpper(s[0..1]) ~ iter!(s[1..$], T);
    }
}

pragma(msg, iter!(x, int));

void main() {}

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