Consider this hypothetical example: ///////////////// test.d ///////////////// T[] copyArray(T=I, I)(I[] input) { auto result = new T[input.length]; foreach (n, ref i; input) result[n] = i; return result; } void main() { // copy as is int[] r1 = copyArray([1, 2, 3]); // copy to another type long[] r2 = copyArray!long([1, 2, 3]); } ////////////////////////////////////////// There is currently no way to get this code to work, without either declaring an overload for copyArray, or replacing T=I with T=SomeDummyType and later checking to see if something was explicitly passed or not.
Related: issue #10228
It's not an "hypothetical example" - it makes real code ugly! :/ Let me add an example from a recent PR in phobos https://github.com/dlang/phobos/pull/4263 If we could support the forwarding of argument types, we would only have _one_, very nice & readable function header: ``` T[] makeArray(T = Unqual!(ElementType!R), Allocator, R) ``` Of course we can add another function overload, but it unnecessary bloats! ``` Unqual!(ElementType!R)[] makeArray(Allocator, R)(auto ref Allocator alloc, R range) { import std.range.primitives; alias T = Unqual!(ElementType!R); return makeArray!(T, Allocator, R)(alloc, range); } T[] makeArray(T, Allocator, R)(auto ref Allocator alloc, R range) ```
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/18798 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB