Namespaces
Variants
Actions

Talk:intro/scope

From cppreference.com

I miss a section about variable lifetime. Maybe this is the space that needs to be extended with a teaser, maybe we should create a separate section. I'm in trouble at intro/types when discussing arrays. What should I tell them where to go if they want to know about 'heap' and 'stack'? Nil (talk) 04:51, 22 January 2014 (PST)

Hi. Thanks for your work improving the wiki :) Overall I think variable lifetime belongs here, maybe in a new subsection. Perhaps it's worth not to say anything about the difference between stack and heap yet and keep showing only stack-based variables in the examples. The 'intro' part of the wiki is supposed to teach the basics of C++ without diving into the complexity. Given that all the various containers and smart pointers make raw dynamic allocation seldom needed, we can get away with not showing it at all. Lets keep it for the advanced part of the wiki where we can teach all the peculiarities.
By the way, could you make your examples consistent with the rest of the wiki? That is, 4 space indentation, small_case capitalization (except type names), not using using namespace std; and calling << '\n' instead of << std::endl (which is equivalent << '\n' << std::flush. We don't need to flush the stream most of the time). Thanks :-)
--P12 08:09, 22 January 2014 (PST)
I will try to say as little as I can about it. Also, maybe I will have to move or delete some content that is already done, or replace them with references to the advanced section.
Indentation consistency: OK. IMHO using namespace std; is not a problem inside functions, but if it is a convention to not use it then I won't. End lines: OK. Nil (talk) 08:41, 22 January 2014 (PST)
Nil (talk) 08:41, 22 January 2014 (PST)
Thanks for understanding. I think that moving instead of deleting is a better idea, since it's always easier to start writing about a topic when there's already something written. As for the std namespace, I agree that it sometimes makes sense adding using namespace std;. However, it's worth to keep in mind that beginners often don't have good judgement yet about when that statement is truly useful. So I guess it's a good idea to teach them to always add std::. Once they know enough they would be able to decide for themselves :-) --P12 09:21, 22 January 2014 (PST)