On 02/01/2010 04:19 PM, daoryn wrote:

The whole point of specialisation (and of templates in general) is to have 
functions that work for any type. Having to forcibly specify a type is like 
casting to a specific overload of a function. Why add clutter to the syntax 
when the language advertises automatic type inference?

I disagree. The whole point of specialization is to isolate specific cases that you want to handle differently. The point of templates (probably not in whole) is to parameterize types. The point of argument deduction is, as you put it, to have functions that work for any type.

I do agree that you shouldn't be having any problem whatsoever, but my previous example illustrated that specialization is not at fault. DMD just can't deduce what T is given the argument either because the syntax logically doesn't make sense, or because DMD is retarded.

try compiling the following:

import std.stdio;
void print(T:T[])(T[] thing){
    writeln("Calling print(T[])");
    writeln(T.stringof);
}
void main()
{
print([1,2,3]);
}

it gives me:

test.d(8): Error: template test.print(T : T[]) does not match any function template declaration test.d(8): Error: template test.print(T : T[]) cannot deduce template function from argument types !()(int[3u])


Reply via email to