svn commit: r268491 - head/usr.bin/users

Pietro Cerutti gahr at FreeBSD.org
Tue Jul 15 19:21:55 UTC 2014


On 2014-Jul-10, 11:27, John Baldwin wrote:
> I would also prefer avoiding 'using namespace' when possible, especially
> for a short program.

On 2014-Jul-11, 17:26, John Baldwin wrote:
> I suppose it would be fine to permit it in small utilities and only in .cc
> files but not otherwise?

I'm confused.

On 2014-Jul-11, 10:03, John Baldwin wrote:

> http://stackoverflow.com/questions/1452721/why-is-using-namespace-std-considered-bad-practice
> 
> is a decent start on the multitude of reasons to avoid using it.

I have read the article. The "multitude of reasons" actually boils down
to one single potential problem: namespace pollution.

I agree that this might lead to having sneaky problems which are hard to
debug and so on, but the point remains that namespace pollution is the
only potential problem of "using" declarations.

There's an answer to that SO article that starts with:

"Experienced programmers use whatever solves their problems and avoid
whatever creates new problems."

And I really think that this is the bottom line. Like any feature,
"using" declarations can be good or bad, depending how one uses them.

In this particular case, I have a tiny c++ program and I decided to pull
in the std namespace because:

- it's not going to bother anybody else (read: consumers of my code)
- it improves code readability by avoiding std:: all over the place

Bottom line: I'd agree to a rule to avoid using directive and
declarations in header files, but please don't stigmatize "using" as an
intrinsically bad thing.

p.s. Same has been done to "goto" for decades, and we all know there are
very good cases - although limited in number of occurrences throughout
the average code - where goto is the right thing.

-- 
Pietro Cerutti
The FreeBSD Project
gahr at FreeBSD.org

PGP Public Key:
http://gahr.ch/pgp
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 949 bytes
Desc: not available
URL: <http://lists.freebsd.org/pipermail/svn-src-head/attachments/20140715/bdeea4c8/attachment.sig>


More information about the svn-src-head mailing list