Namespaces
Variants
Views
Actions

Talk:cpp/language/for

From cppreference.com

I am quite new here and I don't know what is the official rules contributing to the articles. I added an example of for loop iterating within a sample STL container [1]. I hope, that an extra example is ok. Ggia 09:44, 30 December 2012 (PST)

I believe the admins' preference is to have a single example that illustrates multiple points if necessary. The focus is on providing a complete C++ reference, rather than being a tutorial or a style guide. --Cubbi 07:01, 31 December 2012 (PST)
I can understand this view. But putting more than one example it doesn't turn the article to a programming cookbook. The [2] example shows a common use of for loop iterating with containers (before the introduction of Range-based for loop in C++11). Ggia 08:14, 1 January 2013 (PST)
I don't think we always need to have just a single example, but when we're just demonstrating several variations on a common theme, I think a single example works best. Since this seemed like a case of that, I went ahead and merged the second example with the first.
I think our goal for example code should be to provide the smallest possible bit of code that still clearly explains the concept at hand. Having repeated boilerplate is just more stuff that users have to slog through in order to find what they're looking for. However, multiple separate examples could work well if we're trying to depict use cases that are quite different. --Nate 08:24, 1 January 2013 (PST)