D2.x writef et al and template bloat
BCS
ao at pathlink.com
Tue Oct 16 14:08:15 PDT 2007
Reply to Walter,
> 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.
>
If you want to known how many cases there are you can add a pragma(msg, formatTypeTupleTemplateWidgit!(args))
to wrightf and then filter the output for unique lines.
More information about the Digitalmars-d
mailing list