Mixin can't access library symbols?

Adam D. Ruppe destructionator at gmail.com
Sat May 4 14:22:45 UTC 2019


On Saturday, 4 May 2019 at 08:12:46 UTC, Alex wrote:
>>     mixin(defState!("XEvent value;"));
> mixin templates are used in the call scope, not the defining 
> scope.

That's true, but the code there is NOT a mixin template.

mixin templates are always used

mixin TemplateName;

or

mixin TemplateName!(Args);


There are no parenthesis around it for this construct.

> Sometimes this is a little tricky because you want to 
> generalize it so you have to do some weird stuff and use 
> mixin("import "~moduleName!T~";");

If you find yourself writing code like that, it means your 
library is badly designed and you should fix it. There is never a 
need for that, if you can get the module if T, it means you 
*already have access to T* and can simply use it directly.


More information about the Digitalmars-d-learn mailing list