Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 11 Jul 2014 17:26:14 -0400
From:      John Baldwin <jhb@freebsd.org>
To:        David Chisnall <theraven@freebsd.org>
Cc:        Ed Schouten <ed@80386.nl>, src-committers@freebsd.org, Ian Lepore <ian@freebsd.org>, svn-src-all@freebsd.org, Pietro Cerutti <gahr@freebsd.org>, svn-src-head@freebsd.org
Subject:   Re: svn commit: r268491 - head/usr.bin/users
Message-ID:  <201407111726.14347.jhb@freebsd.org>
In-Reply-To: <12328E44-58A8-4334-A7F4-C7F29C9F6D0E@FreeBSD.org>
References:  <201407101215.s6ACF3v1055260@svn.freebsd.org> <201407111003.57785.jhb@freebsd.org> <12328E44-58A8-4334-A7F4-C7F29C9F6D0E@FreeBSD.org>

next in thread | previous in thread | raw e-mail | index | archive | help
On Friday, July 11, 2014 3:38:16 pm David Chisnall wrote:
> On 11 Jul 2014, at 15:03, John Baldwin <jhb@FreeBSD.org> 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 also avoid 'import * from foo' in Python for similar reasons.
> > 
> > OTOH, most of the C++ code bases I've had to work with do have a global
> > 'using namespace std'.  Great fun when someone decides it would be
> > convenient to add 'using namespace boost' to the mix.
> 
> Note that, even though 'using namespace std' is a bad idea, 'using std::vector; using std::string' and so on is not so bad. 

Agreed, I have used 'import Foo from Bar' in python as well.

> For things that live in the base system, there's not much danger of boost conflicts.  'using namespace std' is mostly a problem when it's in headers (especially 
library headers), because it can break large amounts of code.  In a tiny utility, it's probably the right thing to do.

The original question was about a general style rule for C++ code in FreeBSD.
I suppose it would be fine to permit it in small utilities and only in .cc
files but not otherwise?

-- 
John Baldwin



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201407111726.14347.jhb>