Topic: Definition namespaces (was: template block proposal to simplify
Author: musiphil@bawi.org (KIM Seungbeom)
Date: Fri, 31 Jan 2003 16:23:24 +0000 (UTC) Raw View
"David B. Held" wrote:
>
> "KIM Seungbeom" <musiphil@bawi.org> wrote in message
> news:3E38AD23.CD8B12EF@bawi.org...
> > [...]
> > Do we really have to use a keyword for this?
> > Magnus Lidbom suggested suggested a syntax that use one:
> >
> > class Foo::
> > {
> > int f() const
> > {
> > //...
> > }
> > };
>
> This looks too much like a declaration for my tastes. It's not
> sufficiently different from a declaration to indicate to me that it's
> only a definition namespace, and not a full reopening of the class.
> Whereas:
>
> namespace class Foo
> {
> int f() const
> {
> // ...
> }
> }
>
> tells me that this is fundamentally different from reopening a
> class, which is exactly the case. Also, note the peculiarity with
> the terminating semicolon. In your example, that comes from
> class declaration syntax, because one can put an identifier after
> the declaration. Can they also put an identifier after the
> definition namespace? I.e.:
>
> class Foo::
> {
> // ...
> } foo;
>
> ;> Note that 'namespace' has no such peculiarity.
Okay, I admit that I'm not advocating that syntax in particular,
but it was an example of not using a keyword.. We could drop the
terminating semicolon, or devise a whatever better syntax.
The fact is that I still don't see why many folks here say that
classes are namespaces. A class constitutes a scope, and so does
a namespace. A class scope and a namespace scope are different.
The standard makes it clear what a 'namespace' means, and I don't
think it is what the people here is talking about.
KIM Seungbeom wrote:
>
> I'm not sure if it would be really good to use the keyword 'namespace'
> here. A class constitutes a 'name space' (in the general meaning), but
> a class is not a 'namespace' (in the C++ specific meaning). Wouldn't
> it be confusing to use the same word for two different things?
--
KIM Seungbeom <musiphil@bawi.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 ]
Author: dave@boost-consulting.com (David Abrahams)
Date: Wed, 22 Jan 2003 07:07:55 +0000 (UTC) Raw View
kanze@gabi-soft.de (James Kanze) writes:
> I sort of agree as well. But in all fairness, it is worth pointing out
> the counter-argument. Today, when I see:
>
> int
> f( int y )
> {
> // ...
> }
>
> I know that it is a global function.
?? Confusion ??
struct X
{
// copying your code here:
int
f( int y )
{
// ...
}
};
namespace Y
{
// copying your code here:
int
f( int y )
{
// ...
}
}
Two non-global functions.
--
David Abrahams
dave@boost-consulting.com * http://www.boost-consulting.com
Boost support, enhancements, training, and commercial distribution
---
[ 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 ]
Author: dave@boost-consulting.com (David Abrahams)
Date: Sat, 18 Jan 2003 02:24:34 +0000 (UTC) Raw View
dheld@codelogicconsulting.com ("David B. Held") writes:
> I actually like the idea of using namespace to create what amounts
> to a type of "with clause". It's like James Kanze's suggestion, only
> without introducing a new keyword. And logically, 'namespace'
> seems most appropriate in this context anyway. However, I would
> rearrange the syntax, so it appears like this:
>
<snip>
> This is really helpful for the nested types, as current C++ requires the
> following syntax:
>
> template <typename T>
> template <typename U>
> typename Goo::nested baz(U t) { ... }
>
> template <typename T>
> template <typename U>
> typename Goo::X<T> biz(T t, U u) { ... }
>
> When Goo and X are long names, this syntax makes it harder to find the
> name of the function. When the template parameter list is much longer,
> the return type alone can take an entire line.
I agree. Repeated boilerplate is bad for maintainability and
usability, but so is sticking implementation details in the interface
description. It would be a lot better if C++ didn't make us choose
between them. "Someone" should write up a proposal for the next
version of the standard.
-Dave
--
David Abrahams
dave@boost-consulting.com * http://www.boost-consulting.com
Boost support, enhancements, training, and commercial distribution
---
[ 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 ]