Compilation times and idiomatic D code

jmh530 via Digitalmars-d digitalmars-d at puremagic.com
Mon Jul 17 05:51:37 PDT 2017


On Saturday, 15 July 2017 at 15:58:12 UTC, Jonathan M Davis wrote:
>
>     int[] a;
>     auto b = a.map!(a => a / 2)();
>     pragma(msg, typeof(b));
>
> then it prints out
>
>     MapResult!(__lambda1, int[])
>
> If you have
>
>     int[] a;
>     auto b = a.map!(a => a / 2)().map!(a => a)();
>     pragma(msg, typeof(b));
>
> then it prints out
>
>     MapResult!(__lambda2, MapResult!(__lambda1, int[]))
>
> If you have
>
>     int[] a;
>     auto b = a.map!(a => a / 2)().map!(a => a)().filter!(a => a 
> < 7)();
>     pragma(msg, typeof(b));
>
> then it prints out
>
>     FilterResult!(__lambda3, MapResult!(__lambda2, 
> MapResult!(__lambda1,
> int[])))
>

Is there any way - theoretically - to compute typeof(b) lazily, 
so that the information is only provided as needed?


More information about the Digitalmars-d mailing list