Variadic templates
BCS
BCS at pathlink.com
Fri Nov 3 09:38:07 PST 2006
Kyle Furlong wrote:
> Benji Smith wrote:
>
>> Craig Black wrote:
>> >> This feature seems to supercede older versions of variadic functions.
>> >> Are there still reasons to use the older approach to variadics?
>>
>> Walter Bright wrote:
>>
>>> That's a very good question, and I don't know the answer.
>>> writefln()'s current implementation may be obsolete. But it's
>>> premature to write its obituary. Let's see how things unfold a bit
>>> first.
>>
>>
>> I'd hate to think that every call to a variadic function would require
>> a template instantiation. Doesn't seem like it'd be very efficient.
>>
>> --benji
>
>
> Wait, templating function calls incurs a runtime penalty?
To some extent, yes. having templated function increases the memory
footprint and working set of the program and can cause more swapping and
cash misses.
Another problem with deprecating varidic function would be the template
varidic functions have different types:
<code>
// silly example
void function(...) printer;
if(hasEOL)
printer = &writef;
else
printer = &writefln;
printer("the first thing is: %s", GetString());
printer("the second thing is: %s", GetOtherString());
</code>
The problem is that template varidics operate at compile time, not run time.
More information about the Digitalmars-d
mailing list