From owner-svn-src-head@FreeBSD.ORG Tue Jul 15 19:21:55 2014 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from ptrcrt.ch (freefall.freebsd.org [IPv6:2001:1900:2254:206c::16:87]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 62800AFE; Tue, 15 Jul 2014 19:21:53 +0000 (UTC) Date: Tue, 15 Jul 2014 21:21:49 +0200 From: Pietro Cerutti To: John Baldwin Subject: Re: svn commit: r268491 - head/usr.bin/users Message-ID: <20140715192149.GR1812@ptrcrt.ch> Reply-To: gahr@FreeBSD.org References: <201407101215.s6ACF3v1055260@svn.freebsd.org> <201407111003.57785.jhb@freebsd.org> <12328E44-58A8-4334-A7F4-C7F29C9F6D0E@FreeBSD.org> <201407111726.14347.jhb@freebsd.org> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="15k5Fuw+yLfT1d9X" Content-Disposition: inline In-Reply-To: <201407111726.14347.jhb@freebsd.org> X-PGP-Key: fp="DA6D E106 A5B8 54B8 5DD8 6D49 ADD0 D38E A192 089E"; id="0xA192089E"; get=; get=; User-Agent: Mutt/1.5.23 (2014-03-12) Cc: Ed Schouten , src-committers@freebsd.org, Ian Lepore , svn-src-all@freebsd.org, David Chisnall , svn-src-head@freebsd.org X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 15 Jul 2014 19:21:55 -0000 --15k5Fuw+yLfT1d9X Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable 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-con= sidered-bad-practice >=20 > 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. --=20 Pietro Cerutti The FreeBSD Project gahr@FreeBSD.org PGP Public Key: http://gahr.ch/pgp --15k5Fuw+yLfT1d9X Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQJ8BAEBCgBmBQJTxX9NXxSAAAAAAC4AKGlzc3Vlci1mcHJAbm90YXRpb25zLm9w ZW5wZ3AuZmlmdGhob3JzZW1hbi5uZXREQTZERTEwNkE1Qjg1NEI4NUREODZENDlB REQwRDM4RUExOTIwODlFAAoJEK3Q046hkgie3mYP/Rx9HrqAs48Cf9+gqchq+YWL Iuq8c69WldsvP5ZhhRodFJ/lTi1hc4mUkPKKFh9oYsy2/CQbFG1nIWGhQ3d9cuSr Zqz351DmpKw7ikMDh8yMDOlb4gA5/VyHlk4XjTvRUDWky9SLmGx/HWuN/rHE3KLw ygLT1LIaUjNc/oOOgYsOWpKeVwwd09WszPB+9abEiWIWxjB5q0nnLIKks190mbed prjOsDM35T2Qv5E+U6MNwWjHhVx45deNM+i4Z/gJfLWWX+9gYF+tS+TmYUEu/5RD P9i1p4VY9UVM43vfWfh3pRTP6gXgg5KhIrQLTmKWD7mhW/wKuPfIvSEEUxjLiCw/ 3jvPJQR7AfTlmQ0F9GkCZnCHv/bmjrbl2X55nPuGx5OJAjymFDG+e7HW5Qf1kJ+g kwSKktH0I7gtw0EFQCdOOkPzGT33OOlJaOdfNkexC72kDUXJU0Qwr4xkyUQ8qipK YSWx3fJw5dHpo8piKHWkiqqQAL8qnAgX+9h+uUelIs2Dj+z/tF+TTe8Ueb5QfjFQ 9X3LX05aY4s9dc1a82DFZuLVnXdQTeAupJqzi0tAwEAKIpHNfGCGBlliQIeKK24w 2Fyhlw+WPfGziqTDRzgKAYNFN6mf5fSHKQEOwGT1V6IfHCoX8Pp2mQgzKqaI9YgX Ejl73FMPie4dlDMY15HR =UuEE -----END PGP SIGNATURE----- --15k5Fuw+yLfT1d9X--