Thread overview | |||||
---|---|---|---|---|---|
|
August 24, 2011 [Issue 6550] New: Allow (auto var = expression) in while() loops | ||||
---|---|---|---|---|
| ||||
http://d.puremagic.com/issues/show_bug.cgi?id=6550 Summary: Allow (auto var = expression) in while() loops Product: D Version: D2 Platform: Other OS/Version: All Status: NEW Severity: enhancement Priority: P2 Component: DMD AssignedTo: nobody@puremagic.com ReportedBy: andrej.mitrovich@gmail.com --- Comment #0 from Andrej Mitrovic <andrej.mitrovich@gmail.com> 2011-08-24 12:42:26 PDT --- Currently this doesn't compile: while (auto parent = foo.parent) { foo = parent; } Error: expression expected, not 'auto' This is useful to replace this kind of loop (assume foo is a class object that has a 'parent' field): while (true) { if (auto parent = foo.parent) { // do something with parent foo = parent; // switch to next parent } else { break; } } with the simpler: while (auto parent = foo.parent) { // do something with parent foo = parent; // switch to next parent } Currently `if` statements already allow this syntax, so it seems natural to extend this to `while` loops. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
August 24, 2011 [Issue 6550] Allow (auto var = expression) in while() loops | ||||
---|---|---|---|---|
| ||||
Posted in reply to Andrej Mitrovic | http://d.puremagic.com/issues/show_bug.cgi?id=6550 timon.gehr@gmx.ch changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |timon.gehr@gmx.ch --- Comment #1 from timon.gehr@gmx.ch 2011-08-24 13:12:24 PDT --- note that this can be implemented with a simple rewrite rule. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
August 27, 2011 [Issue 6550] Allow (auto var = expression) in while() loops | ||||
---|---|---|---|---|
| ||||
Posted in reply to Andrej Mitrovic | http://d.puremagic.com/issues/show_bug.cgi?id=6550 yebblies <yebblies@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED CC| |yebblies@gmail.com Resolution| |DUPLICATE --- Comment #2 from yebblies <yebblies@gmail.com> 2011-08-28 02:17:45 EST --- *** This issue has been marked as a duplicate of issue 5432 *** -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
Copyright © 1999-2021 by the D Language Foundation