No header files?

Walter Bright newshound1 at digitalmars.com
Thu Oct 22 00:40:50 PDT 2009


Steven Schveighoffer wrote:
> On Wed, 21 Oct 2009 19:21:32 -0400, Walter Bright 
> <newshound1 at digitalmars.com> wrote:
> 
>> Yigal Chripun wrote:
>>> The C/C++ way of headers + lib has problems which D inherited as part 
>>> of the same (broken) design.
>>
>> Hardly, as:
>>
>> 1. you don't need to use header files in D at all
>>
>> 2. you can automatically generate .di files, guaranteeing they are not 
>> out of sync
> 
> That second one is not true if you are doing incremental building (ever 
> use a build tool that occasionally screws up and doesn't rebuild 
> something?).

At least it is possible to automate. You cannot automate C/C++ header 
files, so they are inherently unreliable.

> In addition, the only *true* reason to use .di files is to 
> hide implementation

It's also to speed up compilation.

> -- which the auto generator does *not* do.  So you 
> are back to hand editing and back to sync problems.

If you need to hide implementation, I suggest instead redesigning your 
interface to use "interface" types, or use the pimpl idiom.

> IMO .di files are as horrible as header files in C and I avoid them like 
> the plague.  I'd hate to have to use them, but so far, I haven't had any 
> public release of proprietary code, so no need for them yet.

I agree they aren't necessary most of the time, I don't agree they are 
even as close to being as horrible as C headers, unless you are 
hand-editting them. If you are doing the latter, I suggest something may 
have gone wrong with the design of your interface.



More information about the Digitalmars-d mailing list