Either I'm just too stupid, or D is lacking something

Sean Kelly sean at f4.ca
Tue Jul 25 06:57:20 PDT 2006


Oskar Linde wrote:
> Wolfgang Draxinger skrev:
>> Andrei Khropov wrote:
>>
>>> Looks like we have only '@' symbol to use.
>>
>> Looks nice, too.
>>  
>>> What you are talking about is actually more powerful
>>> metaprogramming. I'm afraid it's postponed to D 2.0.
>>
>> Sad, that would have made my engine's source code, especially in
>> the renderer part a lot of shorter and readable.
>>
>> But may I make a suggestion for D 1.0 here, that would at least
>> allow usage as I have in mind, i.e. using template mixins as a
>> stock function generator, by adding following rule to templates:
>>
>> If a template only contains functions of the name of the
>> template, and the function declarations adhere the overloading
>> rules the template is a multifunction template.
> 
> Exactly this has been suggested several times before:
> 
> Eg:
> 
> http://www.digitalmars.com/d/archives/digitalmars/D/30234.html
> 
> and
> 
> http://www.digitalmars.com/d/archives/digitalmars/D/38389.html
> 
> It is a minor change, but would break existing code, so getting it 
> before 1.0 would be preferred.

This may make IFTI much more achievable in the short-term, as 
overloading template functions basically doesn't work at all now.  I 
think mixing the two might be more complicated for the compiler to sort out:

template fn( T )
{
     void fn( T[] x ) {}
     void fn( T x ) {}
}

template fn( T : int[] )
{
     void fn( T[] x ) {}
}

template fn( T : int )
{
     void fn( T x ) {}
}

But I suppose that's up to Walter to decide.


Sean



More information about the Digitalmars-d mailing list