[webkit-dev] "using namespace" style guideline

Darin Adler darin at apple.com
Mon Nov 16 13:28:47 PST 2009


On Nov 15, 2009, at 9:57 PM, Chris Jerdonek wrote:

> 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?

This is fine.

If the "using namespace" is scoped to a particular function, then it’s not the same thing we’re talking about.

> 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".

JavaScriptGlue does not follow the WebKit coding style — there’s no need to look at files inside the JavaScriptGlue directory when considering matters of style.

> 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.

Probably. We’d have to discuss specific examples to be sure.

    -- Darin



More information about the webkit-dev mailing list