[Dlang-internal] di files vs CTFE

Jacob Carlborg via Dlang-internal dlang-internal at puremagic.com
Sat Aug 5 01:00:48 PDT 2017


On 2017-08-04 15:55, Jean-Louis Leroy wrote:

> 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've used that workaround as well. If you still want to go with the 
template, I recommend making the template argument empty:

string registerMethods()(string moduleName = __MODULE__)

Otherwise you'll get a new template instantiation for each call to the 
function where the module is different.

-- 
/Jacob Carlborg


More information about the Dlang-internal mailing list