const debacle

Lars Ivar Igesund larsivar at igesund.net
Sat Mar 22 07:32:38 PDT 2008


e-t172 wrote:

> Janice Caron a écrit :
>> On 22/03/2008, e-t172 <e-t172 at akegroup.org> wrote:
>>>  A better
>>>  idea would be to include a new "feature" in D 2.0, i.e. "compiled
>>>  templates", with a new syntax like this :
>>>
>>>  T[] trim(T # [char,dchar,wchar]) (T[] source)
>> 
>> I believe you can already do that - albeit with a different syntax.
>> 
>>     T[] trim(T) (T[] source)
>>     {
>>         /*...*/
>>     }
>> 
>>     private
>>     {
>>         alias trim!(char) dummy1;
>>         alias trim!(wchar) dummy2;
>>         alias trim!(dchar) dummy3;
>>     }
>> 
>> I think those aliases will force an instantiation.
> 
> As a matter of fact, it does, I just tried it. I learned something today
> :)
> 
> Now library developers just have to begin using this kind of aliases for
> templates which get only used with a few, known types, like in
> tango.text.Util.

They're not because current tool chain is not able to remove the unused
variations from the executables, thus you're likely to get 3 times the
codegen that you need, also called bloat.

-- 
Lars Ivar Igesund
blog at http://larsivi.net
DSource, #d.tango & #D: larsivi
Dancing the Tango



More information about the Digitalmars-d mailing list