C++Talk.NET Forum Index C++Talk.NET
C++ language newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Nested namespaces definition

 
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ language, library and standards
View previous topic :: View next topic  
Author Message
adeht
Guest





PostPosted: Tue Apr 13, 2004 8:18 pm    Post subject: Nested namespaces definition Reply with quote



Why won't the standard allow the following?

namespace MyNS::Private
{
// ...
}

---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html ]

Back to top
Steven T. Hatton
Guest





PostPosted: Wed Apr 14, 2004 5:44 pm    Post subject: Re: Nested namespaces definition Reply with quote



adeht wrote:

Quote:
Why won't the standard allow the following?

namespace MyNS::Private
{
// ...
}


This is something Mathematica supports for its packages. I've wondered the
same thing. I haven't proposed this for C++ simply because I had not come
across a use for it in C++. How would such a construct benefit the
language?

--
STH
http://www.kdevelop.org
http://www.suse.com
http://www.mozilla.org

---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html ]


Back to top
adeht
Guest





PostPosted: Wed Apr 14, 2004 6:58 pm    Post subject: Re: Nested namespaces definition Reply with quote



""Steven T. Hatton"" <hattons (AT) globalsymmetry (DOT) com> wrote

Quote:
This is something Mathematica supports for its packages. I've wondered the
same thing. I haven't proposed this for C++ simply because I had not come
across a use for it in C++. How would such a construct benefit the
language?

I didn't search, sorry about that. Here's the proposal:
http://anubis.dkuug.dk/jtc1/sc22/wg21/docs/papers/2003/n1524.htm

You can read about the possible uses for that in the paper.

---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html ]


Back to top
Carl Daniel
Guest





PostPosted: Thu Apr 15, 2004 5:01 am    Post subject: Re: Nested namespaces definition Reply with quote

"adeht" wrote:
Quote:
Why won't the standard allow the following?

namespace MyNS::Private
{
// ...
}

because

namespace MyNS
{
namespace Private
{
// ...
}
}

works just fine as-is.

Analogously, you can't write

class MyNS::MyClass
{
// ...
};

but have to write

namespace MyNS
{
class MyClass
{
//...
};
}

-cd

---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html ]


Back to top
Randy Maddox
Guest





PostPosted: Thu Apr 15, 2004 5:06 am    Post subject: Re: Nested namespaces definition Reply with quote

[email]ab4ds (AT) hotmail (DOT) com[/email] ("adeht") wrote in message news:<407c201b$1 (AT) news (DOT) bezeqint.net>...
Quote:
Why won't the standard allow the following?

namespace MyNS::Private
{
// ...
}


Perhaps because you can accomplish what you want with:

namespace MyNS
{
namespace Private
{
}
}

Then anything in Private is accessed as MyNS::Private::whatever.

Randy.

---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html ]


Back to top
Steven T. Hatton
Guest





PostPosted: Thu Apr 15, 2004 5:09 pm    Post subject: Namespace private context, was Re: Nested namespaces definit Reply with quote

adeht wrote:

Quote:
""Steven T. Hatton"" <hattons (AT) globalsymmetry (DOT) com> wrote in message
news:P4WdnbJgqdLx8-DdRVn-vA (AT) speakeasy (DOT) net...
This is something Mathematica supports for its packages. I've wondered
the
same thing. I haven't proposed this for C++ simply because I had not
come
across a use for it in C++. How would such a construct benefit the
language?

I didn't search, sorry about that. Here's the proposal:
http://anubis.dkuug.dk/jtc1/sc22/wg21/docs/papers/2003/n1524.htm

You can read about the possible uses for that in the paper.

I guess I didn't understand what you were suggesting. My response was
addressing the "Private" concept suggested by your example. In
Mathematica, there is something called a package which functions much like
a namespace in C++. One feature is a mechanism to declare a private
context within a package. This is analogous to the private declaration
mechanism used in C++ classes.

More discussion of Mathematica packages can be found here:
http://documents.wolfram.com/v5/TheMathematicaBook/PrinciplesOfMathematica/ModularityAndTheNamingOfThings/2.7.10.html

This could conceivably be used in C++ to hide namespace local code that is
only needed internally to the namespace. As I said, I haven't found a
compelling argument for suggesting this for C++, but since your example
hinted at such a thing, I thought it would be worth bringing to people's
attention.

And then there is the obvious 'protected' access specifier which might be
used to share implementation details with more deepley nested namespaces.
One implementation of this concept might look something like the following:

namespace nsA {
private:
//nsA local accessible
namespace nsAPriv {
//accessible to nsA only
}
protected:
//accessable to nsA and anything under nsA
namespace nsAProt {
//accessible to nsA and namespaces under nsA
}
public:
//the same as it is now
namespace nsAPub {
// can access nsA public and protected but not private
// accessible to anything that can access nsA public
}
}

Is it useful? I can't offer a compelling argument for it. The concept,
however, seems worth considering.

--
STH
http://www.kdevelop.org
http://www.suse.com
http://www.mozilla.org

---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html ]


Back to top
Display posts from previous:   
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ language, library and standards All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.