Mixin and imports

FunkyD MrFunky at YourDaddy.com
Mon Jun 8 12:39:50 UTC 2020


On Monday, 8 June 2020 at 10:41:53 UTC, jmh530 wrote:
> On Monday, 8 June 2020 at 10:28:39 UTC, Paul Backus wrote:
>> [snip]
>
> Thanks for that suggestion. That works for me.
>
> Unfortunately, it's probably not worth the extra effort though, 
> versus doing foo!fabs in my case.

If they are all from std.math you can easily mixin in the 
template.

just import std.math there then it should work.

If you want more general arbitrary functions you can get the 
module of the function by using an alias. Alternatively you can 
just pass the function itself as an alias or template parameter. 
There are ways to do what you want but it's kinda hacky. I can't 
remember the details though. Basically you use mixins and traits 
to get the module the symbol exists in and then you can use a 
string mixin to import that module.



More information about the Digitalmars-d-learn mailing list