Thread overview
[Issue 6616] New: foreach argument type inference
Sep 07, 2011
yebblies
Sep 07, 2011
yebblies
September 07, 2011
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


--- Comment #0 from bearophile_hugs@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: -------
September 07, 2011
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


--- Comment #1 from yebblies <yebblies@gmail.com> 2011-09-07 18:14:50 EST ---
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: -------
September 07, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=6616



--- Comment #2 from bearophile_hugs@eml.cc 2011-09-07 02:07:39 PDT ---
I am sorry.

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



--- Comment #3 from yebblies <yebblies@gmail.com> 2011-09-07 19:15:27 EST ---
(In reply to comment #2)
> 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: -------