Re: post-c++0x: modules in c++
  Home FAQ Contact Sign in
comp.lang.c++.moderated only
 
Advanced search
POPULAR GROUPS

more...

comp.lang.c++.moderated Profile…
 Up
Re: post-c++0x: modules in c++         


Author: dizzy
Date: Feb 27, 2008 08:53

Hello

german diago wrote:
> Hello. I've been checking the proposal to add modules to C++ and it's
> great! I know there's quite a few time left for that proposal to be
> added to the language. But anyway, I have some suggestions for modules
> in C++. I know it's not a finished proposal, so maybe what I say here
> is quite obvious but has not been included in the paper.
>
> The paper is here:
>
> http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2316.pdf
>
> 2.- When using an import directive, I think that it would be useful
> that the import directive had an implicit using namespace, because
> it's soooo verbose to use today's c++ with namespaces, that people (at
> least this is true for me and some friends I know) don't nest more
> than two namespace just because of its verbosity.
Show full article (4.11Kb)
5 Comments
Re: post-c++0x: modules in c++         


Author: german diago
Date: Feb 28, 2008 15:09

> 1. if the namespace is very big named (including the nesting and such), but
> here a better option is a local shorter namespace alias

You needn't to get the nesting symbols, since you can make private the
nested namespaces
and symbols that won't get exported in modules (that's the point of
modules)
. Please, read the proposal, you got confused I think.
> 2. if the namespace has not many "generic" names (std is the opposite,
> having alot of too general names such as "list", "vector", "pair" that have
> high chance of name clashes)

You can still fully qualify names (to disambiguate), like you do in
your code,
and still wouldn't be so verbose
as the one you get today.
> 3. if the "using namespace" is done in a very local context, such as a
> function body or a "cpp" file (but mandating "import" to do "using
> namespace" breaks this completely since people would want to use "import"
Show full article (6.44Kb)
no comments
Re: post-c++0x: modules in c++         


Author: german diago
Date: Feb 28, 2008 15:09

> I do not agree. If people need "using namepsace" they can do it in the
> current proposal but alot of people (such as myself) do not need it and
> your sugestion would force it for these people. I wouldn't use "using
> namespace" for ANY big namespace with alot of common names (one good
> example is "std" where it makes sense to write "std::list" as oposed to
> just "list" since in a big project you have several kinds of lists from
> various places).

Please. Read the proposal before answering because I think you didn't:

1.- The import directive won't force anyone not to fully qualify names
if they want to.
2.- You can disambiguate std::list or mylib::list if you want to, as
you would do anyway.
> BTW, I am one of those having alot of nested namespaces (max 3 levels, but I
> do have alot of 2 levels namespaces) and I don't mind at all the verbosity
> especially since you can opt it out with "using namespace", "using" or
> namespace aliases to make local short aliases for longer namespaces (such
> as I do for "boost::filesystem" which usually gets a "bfs" alias almost
> everywhere in non-header code).
Show full article (6.57Kb)
no comments
Re: post-c++0x: modules in c++         


Author: german diago
Date: Feb 28, 2008 15:05

On 27 feb, 17:53, dizzy roedu.net> wrote:

I wouldn't use "using
namespace" for ANY big namespace with alot of common names (one good
example is "std" where it makes sense to write "std::list" as oposed
to
just "list" since in a big project you have several kinds of lists
from
various places).

The implicit using directive wouldn't force you not to use std::list
in the
case of ambiguity, so you don't get ANY problem with name clashes. You
are still
allowed to write std::list. This is what C# does. When you write using
System;
you import the namespace. Now you can write System.Console.WriteLine
or simply
Console.WriteLine. And it works pretty well. But I'm not sure if the
mapping in
C++ modules would be similar or not.
Show full article (6.51Kb)
no comments
Re: post-c++0x: modules in c++         


Author: dizzy
Date: Feb 29, 2008 10:42

german diago wrote:
>
>> I do not agree. If people need "using namepsace" they can do it in the
>> current proposal but alot of people (such as myself) do not need it and
>> your sugestion would force it for these people. I wouldn't use "using
>> namespace" for ANY big namespace with alot of common names (one good
>> example is "std" where it makes sense to write "std::list" as oposed to
>> just "list" since in a big project you have several kinds of lists from
>> various places).
>
> Please. Read the proposal before answering because I think you didn't:
>
> 1.- The import directive won't force anyone not to fully qualify names
> if they want to.
> 2.- You can disambiguate std::list or mylib::list if you want to, as
> you would do anyway.
Show full article (7.48Kb)
no comments
Re: post-c++0x: modules in c++         


Author: Martin Bonner
Date: Feb 29, 2008 10:42

On Feb 28, 11:05 pm, german diago gmail.com> wrote:
> On 27 feb, 17:53, dizzy roedu.net> wrote:
>
> I wouldn't use "using
> namespace" for ANY big namespace with alot of common names (one good
> example is "std" where it makes sense to write "std::list" as oposed
> to just "list" since in a big project you have several kinds of lists
> from various places).
>
> The implicit using directive wouldn't force you not to use std::list
> in the case of ambiguity, so you don't get ANY problem with
> name clashes.

Yes you will. The compiler won't be confused, but if I see "list" in
a particular file I will assume that it is std::list (just like in the
other 5000 files in the code-base). However in this particular case,
it may refer to some other list.
Show full article (1.32Kb)
no comments