Re: Why aren't namespaces used more?

Discussion in 'C++' started by Jason, Aug 16, 2003.

  1. Jason

    Jason Guest

    "Andrew Palumbo" <> wrote in message
    news:...
    > Hi,
    >
    > I'm really curious why people don't use namespaces more often. Is it
    > just a matter of laziness and ignorance? What are the major
    > drawbacks? I'd say a good lot of the C++ libraries out there don't
    > use namespaces. At least the ones I've run across. They just pollute
    > the global namespace and hope that your software has the smarts to not
    > link against a mismatched version of their library...
    >
    > Am I missing something, am I just being pessimistic, or do most
    > library authors just really not care?
    >
    > -Andrew


    I think there are a few reasons for it. One could say that some people even
    use them too much - especially if you look at Java and C# class libraries.

    As for polluting namespaces well, it's said that you shouldn't use things
    like :

    using namespace std;

    at the top of your compilation unit. Which may be all well and good, but
    then who wants to type in std::cout etc? It's makes the code quite unwieldy
    to write and read. An the effort doesn't seem worth it. Never mind about
    laziness. It's one of those debatable things. I've yet to find a really
    convincing use for either;

    I'd say a general encapsulating namespace is always useful though, but I am
    not a C++ person myself.
    Jason, Aug 16, 2003
    #1
    1. Advertising

  2. Jason

    David List Guest

    On Sat, 16 Aug 2003 21:43:18 +0100,
    Jason <>
    wrote in <3f3e9815@shknews01>:

    ....<snip>...
    > As for polluting namespaces well, it's said that you shouldn't use things
    > like :
    >
    > using namespace std;
    >
    > at the top of your compilation unit. Which may be all well and good, but
    > then who wants to type in std::cout etc?

    ....<snip>...

    I don't know, but at least not the ones who issue this:

    using std::cout;

    --
    Med venlig hilsen / Best regards
    David List
    David List, Aug 17, 2003
    #2
    1. Advertising

  3. >"Andrew Palumbo" <> wrote in message
    >news:...
    >> Hi,
    >>
    >> I'm really curious why people don't use namespaces more often. Is it
    >> just a matter of laziness and ignorance? What are the major
    >> drawbacks? I'd say a good lot of the C++ libraries out there don't
    >> use namespaces. At least the ones I've run across. They just pollute
    >> the global namespace and hope that your software has the smarts to not
    >> link against a mismatched version of their library...
    >>
    >> Am I missing something, am I just being pessimistic, or do most
    >> library authors just really not care?
    >>
    >> -Andrew


    Another reason is that many embedded compilers have very weak support of
    namespaces (or templates for that matter). I work almost exclusively on
    embedded platforms, and namespaces restrict my choice of compilers.

    Fortunately, most compilers today offer much better support for namespaces.
    Templates, that's still iffy.
    Dave Rahardja, Aug 17, 2003
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Karlo Lozovina
    Replies:
    1
    Views:
    303
    Jonathan Ellis
    Apr 16, 2006
  2. Mr. SweatyFinger

    why why why why why

    Mr. SweatyFinger, Nov 28, 2006, in forum: ASP .Net
    Replies:
    4
    Views:
    874
    Mark Rae
    Dec 21, 2006
  3. Mr. SweatyFinger
    Replies:
    2
    Views:
    1,803
    Smokey Grindel
    Dec 2, 2006
  4. Adam Nielsen
    Replies:
    8
    Views:
    277
    James Kanze
    Jul 30, 2008
  5. Craig
    Replies:
    1
    Views:
    126
Loading...

Share This Page