[Dlang-internal] di files vs CTFE
Jean-Louis Leroy via Dlang-internal
dlang-internal at puremagic.com
Fri Aug 4 06:55:29 PDT 2017
Hi,
While working on my openmethods library, I came across a gap that
may be worth filling.
I have this kind of code:
// in openmethods.d
string registerMethods() { ... }
// in code using the lib
import openmethods;
mixin(registerMethods);
When I add -H, the interface file takes precedence over the
source file, but the body of registerMethods() is removed. I
easily found a workaround - make the function a template (see
here
https://github.com/jll63/openmethods.d/commit/6a7bf93932bebc53fca368e2280c71a0cbbf3c3b) but it's a bit of a hack. I also had to remove a couple of ctors that was there only because of my ignorance at the time.
I tried pragma(inline) but it doesn't preserve the body. Maybe it
should, because you cannot inline without the source. Or maybe we
need another pragma, I couldn't find a nice name but something
along pragma(interface) or pragma(keepBody).
More information about the Dlang-internal
mailing list