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

           Summary: foreach argument type inference
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: DMD
        AssignedTo: nob...@puremagic.com
        ReportedBy: bearophile_h...@eml.cc


--- Comment #0 from bearophile_h...@eml.cc 2011-09-07 00:57:03 PDT ---
In this program the Foo struct is large, so I use ref to avoid its copies. I
also use const because I want to make sure (and document) the two loops will
not change the matrix contents:


struct Foo { int[1000] a; }
void bar(ref Foo x) {}
void main() {
    auto m = new Foo[][](3, 3);
    foreach (const(Foo[]) row; m)
        foreach (ref const(Foo) x; row)
            bar(x);
}


But I'd like type inference there, and be able to write something like:

struct Foo { int[1000] a; }
void bar(ref Foo x) {}
void main() {
    auto m = new Foo[][](3, 3);
    foreach (const row; m)
        foreach (ref const x; row)
            bar(x);
}


With DMD 2.055beta3 this gives:

test.d(5): no identifier for declarator const(row)
test.d(6): no identifier for declarator const(x)

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

Reply via email to