<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">2013/10/4 Robert Schadek <span dir="ltr"><<a href="mailto:realburner@gmx.de" target="_blank">realburner@gmx.de</a>></span><br><blockquote class="gmail_quote" style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<div class="im">On 10/03/2013 08:10 PM, David Nadlinger wrote:<br>
> On Thursday, 3 October 2013 at 17:52:13 UTC, Robert Schadek wrote:<br>
>><br>
</div><div class="im">>> dmd moduleA.d moduleB.d -ofmix -unittest<br>
>> moduleA.d(4): Error: undefined identifier Foo<br>
>> moduleB.d(10): Error: template instance A.func!(Foo) error instantiating<br>
><br>
> Yes, this is indeed very much by design – A does not import B, so<br>
> there is no reason why the name "Foo" should exist in A.<br>
</div>Yes, it does not exists in the module but func is a template and I was<br>
under the impression symbols would be seen when instantiated. I mean the<br>
error starts with A.func!(Foo) error instantiating.<br>
<div class="im">><br>
> To access the template parameter, just use it directly in the mixin<br>
> (as in »mixin("T.fun()")«). I'm aware that the situation where you<br>
> actually stumbled over this is probably a bit more complex, but in my<br>
> experience an equivalent rewrite can almost always be performed quite<br>
> easily once you have wrapped your head around the concept.<br>
</div>Not as easy to fix this as I have a library that generates me sqlite<br>
code at compile time which I than mixin to have as good as handwritten<br>
code. I just found it odd that it works if I instantiate the template<br>
from the same module.<br></blockquote><div><br></div><div>Using built-in 'stringof' property for code generation won't work in general. Instead:</div><div><br></div><div><div>public int func(T)() {</div><div>
return mixin("T" ~ ".fun()");</div><div>}</div><div> <br></div></div><div>Kenji Hara</div></div></div></div>