CTFE and DI: The Crossroads of D
Jonathan M Davis
jmdavisProg at gmx.com
Thu May 10 11:04:34 PDT 2012
On Thursday, May 10, 2012 10:37:58 Adam Wilson wrote:
> Like Steve said, most people generating DI files are not really worried
> about CTFE working, in fact they almost undoubtedly *know* that they are
> breaking CTFE, yet they choose to do it anyways.
Actually, I expect that they _don't_ know in most cases until they've actually
done it and had any CTFE stuff that they do break (or nothing break if they
don't use CTFE).
However, ultimately, if you decide to use .di files, you _are_ choosing between
having a stripped interface and having CTFE and inlinability. So, even if the
programmer is not fully aware of the tradeoffs when they first attempt it,
that's ultimately what they have to decide.
Honestly, I think that if you really want to be using .di files though, in most
cases, you're going to have to maintain them by hand. As such, you basically
have the choice between copying the .d file and then stripping it down by hand
or using the tool to strip it and then adding stuff back in by hand. I really
think that druntime's choice of automatically generating .di files as part of
the build process is a flawed idea in the general case. But it looks like
you've started the process of changing how druntime deals with that.
I would warn you however that taking the approach of just copying the
implementation over for what Phobos needs for CTFE is inherently flawed and
will undoubtedly break existing programs. I'd argue that for the most part,
anything that currently has its implementation in druntime's .di files needs to
keep it. The sole exceptions would be stuff which isn't CTFEable (e.g. the rt
stuff) and stuff which already has a hand-written .di file (like object and
thread). So, you should be erring on the side of not generating the .di file
with your updated .di generator rather than using it as far as druntime goes.
- Jonathan M Davis
More information about the Digitalmars-d
mailing list