DIP22 : Private symbol visibility

Paulo Pinto pjmlp at progtools.org
Fri Feb 1 08:10:04 PST 2013


On Friday, 1 February 2013 at 15:08:00 UTC, Leandro Lucarella 
wrote:
> Dicebot, el  1 de February a las 10:42 me escribiste:
>> Still, no need for internal linkage is felt because D projects 
>> are
>> very small nowadays and does not involve complex separate
>> compilation systems and\or large teams of programmers working 
>> on a
>> single project. What internal linkage gives you is hard 100%
>> guarantee (verified by the compiler) that this piece of code 
>> may be
>> changed as you wish and it won't affect anything but this 
>> module.
>> Private can't give such guarantees without code breakage. It 
>> is a
>> widely used idiom in C/C++ that D currently has no replacement.
>
> Unfortunately D is different in this regard than C/C++ (yes, I 
> said
> unfortunately :P). Separate compilation in D is not that 
> useful, as
> interfaces are not clearly defined (at a file level). When you 
> import
> something, you are importing the implementation, not only the 
> interface.
> Is really hard to decouple both in D. I tried to play around 
> with
> separate (and incremental) compilation in D without much luck. 
> And
> I wonder if it ever will make any sense to compile separately 
> instead of
> all in one go.
>
> Because of this, even when I agree about the goodness of "static
> linkage" (as in C/C++), I don't see real value in this proposal 
> for D.
>
> PS: Yes, I know there are the .di files, but even trying to use 
> that
>     makes thing extremely hard, because you need to parse the 
> whole file
>     to generate it and the difference between parsing and 
> compiling is
>     not that much. And then, as in C++, you have templates.

There are other languages with modules that also have generics,
although not as powerful as D's templates, surely they could be 
used as inspiration for how they are storing information on the 
compiled modules.

--
Paulo


More information about the Digitalmars-d-announce mailing list