Nested public imports - bug or feature?

Jonathan M Davis via Digitalmars-d digitalmars-d at puremagic.com
Thu Aug 13 10:06:16 PDT 2015


On Thursday, 13 August 2015 at 16:40:31 UTC, Dicebot wrote:
> On Thursday, 13 August 2015 at 16:37:00 UTC, Jonathan M Davis 
> wrote:
>> Well, that's better than requiring the full import path, but 
>> requiring _any_ module name is just plain annoying IMHO. If I 
>> were okay with that I wouldn't be doing stuff like
>>
>> using namespace std;
>>
>> in all of my .cpp files - and that's a really common thing to 
>> do.
>
> Matter of scale. At some point of application size maintenance 
> cost become much higher than development costs - and problems 
> of name clashes become more important than any extra typing 
> annoyance.

Well, if name clashes become that high in a .cpp file, odds are 
that it's pulling in too much stuff.

> In my C++ projects such "using" abuse was normally banned.

I've never worked on a team that banned them. Every C++ project 
that I've ever worked on has used them heavily. It's common 
practice for every namespace that's being used in a .cpp file to 
having a corresponding using directive. On the rare cases where 
there's a collision, you then have to be more explicit, but I've 
never seen it be much of a problem - and definitely nowhere near 
enough of a problem to consider banning using directives. I'd 
_hate_ to be writing code that required being that explicit.

- Jonathan M Davis


More information about the Digitalmars-d mailing list