Compilation times and idiomatic D code

Enamex via Digitalmars-d digitalmars-d at puremagic.com
Sat Jul 15 12:11:54 PDT 2017


On Saturday, 15 July 2017 at 15:58:12 UTC, Jonathan M Davis wrote:
> On Saturday, July 15, 2017 11:10:32 Enamex via Digitalmars-d 
> wrote:
>> [...]
> The issue has to do with how each invocation of a range-based 
> function tends to result in a new template instantiation, and 
> it's common practice in D to chain a bunch of templated 
> function calls together. For instance, if you have
>
> [...]
>
> The type is getting progressively longer and more complicated, 
> because when the function template is instantiated, it's 
> instantiated with the type from the previous function call, so 
> it's wrapping the previous type, and you get a new type that 
> has the name of the type of its argument embedded in it. It's 
> like if you keep wrapping a container inside another container.
>
> [...]
>
> - Jonathan M Davis

This was quite insightful, thank you.

All that time I'd assumed that 'symbols' as linkers used them 
were constant length :T

Just to be clear: 100% of that bloat resides in the symbol table? 
So the current proposed remedy is to hash symbols above a length 
threshold?

Besides the symbol problem though, does the template 
instantiation explosion problem imply as many duplicated function 
bodies corresponding to the new type symbols?


More information about the Digitalmars-d mailing list