Overview
Features
Download
Documentation
Community
Add-Ons & Services
The POCO C++ Libraries Blog

Namespaces in POCO

Filed under: Uncategorized by guenter at 17:00

There has been a lot of discussion lately regarding namespaces in POCO. Both the way how namespaces are defined, which is currently done with macros (shudder ;-) ), and the way, namespaces are, well, named.

I am seriously thinking about getting rid of the namespaces macros. After reflecting about it for some time, the main reason why I used them in the first place was just because I was so used to them.

There is one open question, and this is whether we should put everything into a top level Poco namespace, or not.

Personally, I think, one level of namespaces is enough in C++. C++ is not Java, where the runtime requires that everything is in a unique namespace. This is because in Java there is no linker involved, only a class loader. In C++, the developer has direct control over what’s getting linked to his application, so this alone greatly reduces the possibility of naming conflicts.

Nevertheless, with just one level of namespaces, there is a small chance for collissions, especially since we’re using four namespaces (Foundation, XML, Util, Net), and even more in the future.

So, the big question: Should we put everthing into a top-level Poco namespace? Tell me your thoughts!

3 Comments »
  1. I personally would not touch anything. I was not used to namespace macros, got used to them and they seem fine to me now. And then, in case top-level Poco namespace is introduced, I’d change Foundation to Base, because for example, Poco::Foundation::LineEndingConverterStreamBuf
    ,although very clear what and where it is, is a bit over the top with length for my taste.

    But, then again, I’ve seen several complaints (and already talked too much myself) about these topics, so let’s wait and hear more people. It would be good to set up some sort of poll and look at numeric indicators, because I already see this post turning into an endless exchange of opinions.

    Comment by alex on August 6, 2006, 01:22

  2. Yes, *please* get rid of the namespace macros. First and foremost, they ruin all attempts at using intelligent tagging tools. Without even getting into the other ways macros are bad (do I need to?), the tagging problem alone is a killer.

    As for a single namespace? It’s probably fine.

    Comment by Patrick on August 11, 2006, 16:29

  3. Please get rid of the macros. And please use an outermost namespace of POCO. The length of namespaces can always be mitigated when a user of POCO employs namespace aliases. An outermost namespace is the traditional way to ensure that stuff from different packages does not clash, either at linker level or by requiring disambiguation.

    Comment by Andrew Marlow on August 13, 2006, 12:54

RSS RSS feed for comments on this post. TrackBack URI

Leave a comment