www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 6616] New: foreach argument type inference

reply d-bugmail puremagic.com writes:
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: nobody puremagic.com
        ReportedBy: bearophile_hugs eml.cc



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: -------
Sep 07 2011
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=6616


yebblies <yebblies gmail.com> changed:

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



You're kidding me right?  This is the THIRD time you've reported this exact
bug.

*** This issue has been marked as a duplicate of issue 4090 ***

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Sep 07 2011
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=6616




I am sorry.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Sep 07 2011
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=6616





 I am sorry.
Just don't forget to do a quick search first next time! I know you have over 200 enhancement requests open, but it might be worth going through and checking they all still make sense. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Sep 07 2011