digitalmars.D.bugs - [Issue 9009] New: allow foreach without identifier
- d-bugmail puremagic.com Nov 12 2012
- d-bugmail puremagic.com Jan 11 2013
- d-bugmail puremagic.com Jan 13 2013
- d-bugmail puremagic.com Mar 06 2013
- d-bugmail puremagic.com Mar 07 2013
http://d.puremagic.com/issues/show_bug.cgi?id=9009 Summary: allow foreach without identifier Product: D Version: unspecified Platform: All OS/Version: All Status: NEW Severity: enhancement Priority: P2 Component: DMD AssignedTo: nobody puremagic.com ReportedBy: monarchdodra gmail.com --- Comment #0 from monarchdodra gmail.com 2012-11-12 07:57:54 PST --- Minor enhancement request, but the language should allow using "foreach" without specifying an iteration name. THis can be useful when you want to iterate a fixed amount, without caring about the index. For example, when you want to "popFrontN exactly" (popFrontN is safe, so slightly slower), you'd want to write: foreach( ; 0 .. n ) r.popFront(); Right now, if you do this, you get: main.d(5): Error: basic type expected, not ; main.d(5): Error: no identifier for declarator int for can do without declarators, I don't see why foreach can't have the above syntax. Just a minor ER, but I think it would make foreach that little extra user friendly. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Nov 12 2012
http://d.puremagic.com/issues/show_bug.cgi?id=9009 Andrej Mitrovic <andrej.mitrovich gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |andrej.mitrovich gmail.com --- Comment #1 from Andrej Mitrovic <andrej.mitrovich gmail.com> 2013-01-11 17:50:06 PST --- I think this is a worthy request, although you can use "_" as an unused iteration variable you may end up having to invent unique names with 2 or more nested foreach loops: foreach(_; 0 .. n ) { foreach(__; 0 .. m) { // statements } } Since foreach lowers to a for statement I think it should be possible to implement the request. Can we get a pre-approval from Walter/Andrei? -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jan 11 2013
http://d.puremagic.com/issues/show_bug.cgi?id=9009 --- Comment #2 from monarchdodra gmail.com 2013-01-13 13:56:29 PST --- (In reply to comment #1)I think this is a worthy request, although you can use "_" as an unused iteration variable you may end up having to invent unique names with 2 or more nested foreach loops: foreach(_; 0 .. n ) { foreach(__; 0 .. m) { // statements } } Since foreach lowers to a for statement I think it should be possible to implement the request. Can we get a pre-approval from Walter/Andrei?
BTW, given the compiler error that is spit out by DMD upon writing //---- foreach ( ; 0 .. n ) //---- Error: basic type expected, not ; Error: no identifier for declarator int //---- I'd say it is either a bug that this isn't already supported anyway, or the compiler error should be re-written. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jan 13 2013
http://d.puremagic.com/issues/show_bug.cgi?id=9009 bearophile_hugs eml.cc changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |bearophile_hugs eml.cc --- Comment #3 from bearophile_hugs eml.cc 2013-03-06 16:15:47 PST --- I think this is a simple nice idea. There is no point in requiring to name a variable that will not used. It's like in function signatures: void foo(int, int y) {} -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Mar 06 2013
http://d.puremagic.com/issues/show_bug.cgi?id=9009 --- Comment #4 from Andrej Mitrovic <andrej.mitrovich gmail.com> 2013-03-07 07:08:24 PST --- (In reply to comment #3)I think this is a simple nice idea. There is no point in requiring to name a variable that will not used. It's like in function signatures: void foo(int, int y) { }
He meant: void foo(int, int) { } -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Mar 07 2013









d-bugmail puremagic.com 