[Issue 6616] New: foreach argument type inference
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Wed Sep 7 00:57:16 PDT 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 at puremagic.com
ReportedBy: bearophile_hugs at eml.cc
--- Comment #0 from bearophile_hugs at 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: -------
More information about the Digitalmars-d-bugs
mailing list