[webkit-dev] "using namespace" style guideline
darin at apple.com
Thu Nov 12 08:50:11 PST 2009
On Nov 11, 2009, at 6:56 PM, Chris Jerdonek wrote:
> What is the current thinking on all of the "using WTF::..." statements at the end of many header files in JSC? For example, what was the original reason behind including those, and is there any chance that they will be taken out at a later date (or has that already been ruled out)? I searched a bit and didn't come across any discussion of this.
WTF uses namespacing differently than most libraries. We’re using it to disambiguate at link time, but not compile time.Having the symbols in a namespace at link time still has a substantial benefit, so it’s good to put things in a WTF namespace instead of just putting them outside any namespace.
Maciej Stachowiak devised this scheme for WTF, and I think on balance it’s probably a good way to do things although I would probably not have chosen it myself, and would have used the more conventional scheme. Maciej and I and a few others at Apple discussed this a bit a few years back, but nobody on any WebKit mailing list ever raised the issue before.
Since WTF is for use inside WebKit itself, I think we can stick with this approach unless we run into a substantial, concrete problem with it.
For a while I was adding "using namespace WTF" to .cpp files because I did not understand our WTF namespacing approach.
More information about the webkit-dev