Nested public imports - bug or feature?

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


On Thursday, 13 August 2015 at 17:32:33 UTC, Dmitry Olshansky 
wrote:
> On 13-Aug-2015 20:17, Jonathan M Davis wrote:
>> On Thursday, 13 August 2015 at 17:09:11 UTC, Dicebot wrote:
>>> On Thursday, 13 August 2015 at 17:06:18 UTC, Jonathan M Davis 
>>> wrote:
>>>>> 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.
>>>
>>> My projects have been broken twice by adding new functions to 
>>> druntime
>>> (and one was symbol added to object.di :)). Forgive me if I 
>>> discard
>>> that argument as nonsense. If short names are allowed and 
>>> project is
>>> big enough, clashes are simply inevitable. With D module 
>>> system even
>>> medium size will do.
>>
>> Yes. Clashes are going to happen, especially if you're using 
>> short names
>> heavily, but in C++, I've rarely had problems with it. D is 
>> potentially
>> worse,
>
> Because private symbols from imported modules *do* clash with 
> public ones even though not accessible. THAT is the problem and 
> header/source is not the reason of D doing worse here.

Oh. That makes the problem even worse, and it definitely needs to 
be fixed, but the fact that you're essentially forced to use 
fully qualified names in C++ for header files means that you're 
not going to run into name clashes in the public declarations - 
only in the function bodies in the .cpp file - whereas all of 
that is out in the open with .d files. So, the header/source 
separation does reduce the problem in C++, and even if we do fix 
the private symbol mess in D, D will still have more name 
clashing problems because it doesn't normally have that 
separation. But the private symbols affecting the public API is 
just plain embarrassing and definitely makes the problem _far_ 
worse.

- Jonathan M Davis


More information about the Digitalmars-d mailing list