[D-runtime] Why does druntime us .di files instead of .d?

Jonathan M Davis jmdavisProg at gmx.com
Wed Jul 13 15:19:06 PDT 2011


On 2011-07-13 14:58, Walter Bright wrote:
> On 7/13/2011 2:21 PM, Jonathan M Davis wrote:
> > On 2011-07-13 13:36, Walter Bright wrote:
> >> .di files are used when they are generated from .d files.
> > 
> > Yes. I get that. But why are .di files generated in the first place?
> 
> To 1. hide implementation details and 2. speed up compilation.
> 
> > Phobos just uses .d files.
> 
> It'll eventually migrate to .di files.

Given its heavy use of templates, I'm not sure how much that'll buy us in 
terms of compilation speed, and since it's all open source, I don't know why 
it would matter about hiding implementation details. The documentation gives 
the API. You look at the source if you want more than that, in which case you 
probably want the .d file and not a .di file. But I guess that even 
incremental improvements are worth something as far as compilation speed goes, 
and there is a fair bit of functionality which isn't templated (though 
increasingly, I think that it's in the minority).

Regardless, if it's making it so that stuff isn't CTFEable (which at least 
seems to be the case with druntime at the moment - I'm not quite sure what's 
going on there, but people have been getting errors about it), then I would 
think that that would make using .di files a really bad idea in general, since 
you effectively risk killing a language feature - and in the standard library 
no less.

But anyway, thanks for the reasoning on why druntime uses .di files. I've 
always found it odd (and honestly, I still find it odd, but at least 
understandable now). I've never seen much point to .di files at all. But if 
they speed up compilation, then that's definitely of some value.

- Jonathan M Davis


More information about the D-runtime mailing list