super simple code, super slow to compile

Basile B. b2.temp at gmx.com
Sun Mar 31 07:31:57 UTC 2019


On Sunday, 31 March 2019 at 05:37:25 UTC, Basile B. wrote:
> I've found this yesterday while exploring issues:
>
> ---
> import std.typecons: Typedef;
> alias Matrix = double[260][260];
> alias Foo = Typedef!Matrix;
> void main() {}
> ---
>
> It's super slow to compile, here 2 seconds. Change the 
> dimension of the 2nd static array type to 10 and it's more 
> acceptable.
>
> At first glance I'd say that the compiler is doing something 
> stupid.

Well it's not dmd that does something stupid, it's phobos.
Typedef default initializer is stored in the type signature.
  init as template param should be void and in this case void 
would be used to set the payload to the actual init. When people 
want real void init they can do them the classic way anyway

alias M = Typedef!Matrix; // Typedef!(Matrix, void, null);
M m = void;

gotta make a PR lol.



More information about the Digitalmars-d mailing list