http://d.puremagic.com/issues/show_bug.cgi?id=1878
Andrej Mitrovic <[email protected]> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |[email protected] --- Comment #1 from Andrej Mitrovic <[email protected]> 2012-10-28 16:06:36 PDT --- I think a language change might end up breaking code which assumes the index variable is always size_t. The simplest workaround is to type the index variable: foreach (ubyte e; 0 .. limit) writeln(e); Otherwise if we want type inference we could implement a library function: import std.stdio; struct Walk(T) { T idx; T max; @property T front() { return idx; } @property void popFront() { ++idx; } @property bool empty() { return !(idx < max); } } auto walk(L, U)(L lwr, U upr) { assert(lwr <= U.max); return Walk!U(cast(U)lwr, upr); } void main() { ubyte limit = 10; ubyte x; foreach (e; walk(0, limit)) { writefln("%s %s", typeid(e), e); // type is ubyte } } -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
