D import idiom compilation time

Rubn where at is.this
Fri Jan 4 13:07:14 UTC 2019


On Thursday, 3 January 2019 at 23:54:42 UTC, SrMordred wrote:
> There is a veredict about the compilation speedup of the "New 
> Import Idiom"?
>
> Currently i´m using it this way:
>
> struct _std
> {
>   template opDispatch(string moduleName)
>   {
>     mixin("import opDispatch = std." ~ moduleName ~ ";");
>   }
> }
> ...
> //if used single time on scope.
> _std.algorithm.max(a,b);
>
> My question is that, in the long run, this will be worth the 
> compilation time gains, or is just negligible and I should just 
> import the normal way.
> (and keep the code more sane)
>
> Thanks!

I like this idiom way more than the other nasty from!"..." 
syntax. Though you need to define a struct for any library you'd 
want to use it with, not that big of a deal. Thanks for sharing.


More information about the Digitalmars-d mailing list