Siemel said:
For teaching newbies, I think it's best to not even use using namespace
directives at all.
(Plan is: then introduce using declarations like "using N::classname";.
Then Koenig lookup. Then using directives.)
I don't agree with that entirely. In my experience, the more clutter you
introduce into a sample program for teaching purposes - even if it's
just syntactic frosting - the harder it is for the student to swallow
the critical concept that program is trying to get across. In fact,
whenever I've taught (though I'm not a teacher by trade), I prefer to
first show the critical lines that demonstrate the point separate and
non-compilable, then drop those lines into a pre-introduced boilerplate
framework to demonstrate them in action.
Actually, I prefer it when things break - sometimes I even hope for it.
I've never written books or taught by any long-distance methods, so I'm
always standing right there if the learner has a problem. If there were
a namespace collision in a stage of the lesson before namespaces are
introduced, I would call attention to what the problem is, explain why
it has happened, then show a simple workaround (ie, renaming the
identifier so it doesn't conflict). Then when namespaces are discussed
later, I would hark back to the issue, and offer it as real-life
justification for namespaces' existence.
It's also my experience that if you teach a person 10 equivalent ways to
do something, they will almost always use the last way you taught them
exclusively. That's why I've always taught "using" in the order of
directives then declarations. I've always taught Koenig lookup before
either, while describing namespaces in general, but now you've given me
something to think about.
mark