D2.x writef et al and template bloat

Walter Bright newshound1 at digitalmars.com
Tue Oct 16 14:04:18 PDT 2007


Bill Baxter wrote:
> It seems like writef and many other functions got changed to vararg 
> templates in D2.x.

Yes. That makes them run much faster. Instead of interpreting the format 
at runtime, each format gets custom code.

> Doesn't this mean there will be a different instantiation of the writef 
> template for every combination of arguments used to call it?

Yes - but I'll correct that for every *type* combination of arguments.

> Sounds like it could lead to a lot of template bloat in D executables.  Is it a 
> non-issue for some reason?

The linker will remove duplicates. However, I think even in a large 
program, there won't be that many combinations. It also has the 
potential to *reduce* code bloat in small programs, as the unused 
formatting code won't be there.



More information about the Digitalmars-d mailing list