Path: csiph.com!x330-a1.tempe.blueboxinc.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!news.glorb.com!news-out.readnews.com!news-xxxfer.readnews.com!panix!not-for-mail From: Ruben Safir Newsgroups: comp.lang.c++ Subject: Re: Anonymous namespace Date: Mon, 27 Jun 2011 16:34:54 +0000 (UTC) Organization: PANIX Public Access Internet and UNIX, NYC Lines: 70 Message-ID: References: NNTP-Posting-Host: www2.mrbrklyn.com Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Trace: reader1.panix.com 1309192494 19288 96.57.23.82 (27 Jun 2011 16:34:54 GMT) X-Complaints-To: abuse@panix.com NNTP-Posting-Date: Mon, 27 Jun 2011 16:34:54 +0000 (UTC) User-Agent: Pan/0.133 (House of Butterflies) Xref: x330-a1.tempe.blueboxinc.net comp.lang.c++:7185 On Mon, 13 Jun 2011 07:58:12 +0000, Jorgen Grahn wrote: > On Mon, 2011-06-13, ruben safir wrote: >> On Fri, 10 Jun 2011 18:27:29 +0000, Jorgen Grahn wrote: >> >>> On Fri, 2011-06-10, Ruben Safir wrote: >>>> On Thu, 09 Jun 2011 11:26:08 +0000, Jorgen Grahn wrote: >>>> >>>> >>>>>>> namespace unique {} using namespace unique; namespace unique { ... >>>>>>> } >>>>>> >>>>>> ugg - back to the namespace syntax chapter... >>>>> >>>>> If you *do* have a book, >>>> >>>> >>>> Jorgen, do you think I have any C++ references and do you think I >>>> read them. >>> >>> If you had mentioned that you've read book X but still don't >>> understand anonymous namespace because of Y, then I wouldn't have >>> complained. >>> >>> >> I'm partly sympathetic to that point. Your obviously not sitting in my >> chair and you don't really know what I have and haven't read. But I'd >> think that after all those previous posts, you'd have the gist that I'm >> pouring over several texts. > > No, I had missed that. I knew I had read other postings by you, but > didn't remember what they were about. > > ... >> Trying to solve the problem of namespace polution by adding a 100,000 >> extra keystroke, to me is pointless...but that is another issue. I >> have to deal with what C++ is, not what I want it to be. > > I think of namespaces (user-defined, non-anonymous) this way: > > I want the freedom to name things in a straightforward way without > risking clashes with other people's stuff. I don't want to call some > sorting function reorder() just because the standard library used up > the name sort(). And I want the same freedom from conflicts /between/ > subsystems of my own program. > > So I invent the convention of prefixing everything: like my_sort(), > foo_subsystem_sort(), ... > > Namespaces provide a standard way of doing that (my::sort()), and > since it's part of the language it can be smart and not demand the > prefix in contexts where it's /obvious/ which one I mean. And it lets > me manually specify things like "in this context I mean my::sort()". > > So, compared to the manual alternative, you /save/ typing. /If/ you > want to solve the naming problem, that is. > > That's not the only way to think of it, but I find it helpful. > >> (at least it is not tcl) > > Damning with faint praise, are we? ;-) > > /Jorgen So there is one thing I'm still not understanding. If something is declared in a anonymous namespace, how is it accessed in main? Ruben