Talk:Foreach
From Wikipedia, the free encyclopedia
I see the second line of code (DoSomething) as in a box with a blue dotted outline (on FireFox 9.2). Is this normal? It seems to appear whenever I put in 4 spaces at the front of the line to simulate a tab.
Never mind...should have just looked through the editting guidelines. Got it.
[edit] Proposal to merge into For loop
I'm proposing that this article be merged into the For loop article. Please discuss on that article's talk page. — Dmeranda 17:06, 17 May 2006 (UTC)
- Was turned down - see Talk:For loop --Krischik T 14:18, 1 February 2008 (UTC)
[edit] Order of iteration
It is common for a foreach style iteration not to guarantee any particular order of iteration, as comparted to indexed iteration. I think this should be mentioned? putgeminmouth
02:47, 5 May 2007 (UTC)
- I think it depends on the language. In C#, the foreach statement is just a syntactic sugar for which an ordinary loop with an enumerator object manipulated is emitted, so the order of iteration is given by implementation of the underlying enumerator (of couse, if you take an array, stack or a list, their enumerators will enumerate objects in the order you would expect :-)). --Ondrejsv 21:21, 7 July 2007 (UTC)
[edit] Does Smalltalk support foreach nativly?
Smalltalk support for "foreach" seams to be a border line.
While for C++ I think it is clearly an "unsupported" as language does not support foreach and it is emulated by libraries.
Smalltalk too implements foreach as library function. However there is difference: In Smalltalk all control structures are implemented as library features - so I am inclined to see Smalltalks do: [ :each
as first class language feature.