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

Jonathan M Davis jmdavisProg at gmx.com
Wed Jul 13 16:01:46 PDT 2011

On 2011-07-13 15:41, Walter Bright wrote:
> On 7/13/2011 3:19 PM, Jonathan M Davis wrote:
> > 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.
> Consider the garbage collector. Should every compilation have to recompile
> that, too?

Since it doesn't take very long to compile, I really don't care much 
personally, and I think that it's just simpler to only deal with .d files. 
However, I'm not against the use of .di files if it speeds up compilation and 
doesn't have any major drawbacks. My primary concern at the moment (and why I 
brought it up in the first place) is that it seems to be affecting CTFE. For 
instance, this program

import std.stdio;
import std.string;

enum a = strip(" hello world");

void main() {}

currently fails to compile, giving these errors:

/home/jmdavis/dmd2/linux/bin/../../src/phobos/std/string.d(1468): Error: 
_aApplycd2 cannot be interpreted at compile time, because it has no available 
source code
/home/jmdavis/dmd2/linux/bin/../../src/phobos/std/string.d(1521): Error: 
cannot evaluate stripLeft(s) at compile time
/home/jmdavis/dmd2/linux/bin/../../src/phobos/std/string.d(1521): Error: 
cannot evaluate stripRight(stripLeft(s)) at compile time
q.d(4): Error: cannot evaluate strip(" hello world") at compile time

It used to compile prior to 2.054. I don't know whether it's really a CTFE bug 
or if the lack of actual source is really the cause of the problem. But if the 
lack of source _is_ the problem, then that would mean that using .di files 
would tend to make CTFE not work, in which case, I'd argue that we shouldn't 
be using .di files. However, if it's really just a CTFE bug, and .di files 
don't cause any problems for CTFE, then it's fine with me if we use .di files. 
I doubt that I'll ever choose to use .di files in one of my projects, but 
stuff like compilation speed matters that much more when you're dealing with 
the standard library, particularly since it affects everyone using the 

- Jonathan M Davis

More information about the D-runtime mailing list