[webkit-dev] "using namespace" style guideline

Chris Jerdonek chris.jerdonek at gmail.com
Sun Nov 15 21:57:48 PST 2009


On Tue, Nov 10, 2009 at 8:30 PM, Darin Adler <darin at apple.com> wrote:

> No "using namespace" statements are permitted in header files. The guidelines are talking about non-header files. We should clarify that.

Thanks for your later reply explaining the history behind the "using
WTF::..." statements.  It sounds reasonable.

I have a couple more questions related to the rule above though.  (For
everyone else's benefit, this rule now appears on the web site).

I found there to be seven files in WebKit that don't follow this rule,
and I wanted to double-check whether there should be any exceptions to
it.

In particular, the following file uses "using namespace WTF::Unicode"
five times, but within the bodies of various template definitions:

http://trac.webkit.org/browser/trunk/WebCore/platform/text/BidiResolver.h

(see line 304, for example)

Is this also not okay?

The following is another example.  The using statement for this one
appears at the beginning, outside of any definitions, but the file
seems to be central:

http://trac.webkit.org/browser/trunk/JavaScriptGlue/JSUtils.h

It uses "using namespace JSC".

My second question is whether the guideline above should apply, for
the same reason, to all "using" statements within header files -- and
not just to "using namespace" statements.  Statements of the form
"using WTF::..." would be exceptions.  You've already discussed those
here:

https://lists.webkit.org/pipermail/webkit-dev/2009-November/010453.html

I checked, and there are only about 40 files in all of WebKit that
wouldn't currently be following this -- slightly less than half of
which are in JSC.

--Chris


More information about the webkit-dev mailing list