On Tuesday, 10 December 2013 at 07:32:08 UTC, Marco Leise wrote:
[1,2,3] looks like a static array to me. And if overload
resolution picked the most specialized function it seems
natural to call the int[3] version.
My reasoning being that static arrays can be implicitly
converted to dynamic array, but the reverse is not true. So I
think it would be better to have [1,2,3] be a static array and
keep the current behavoir, no?)

In early D1 age, array literals and string literals had had static array types which corresponding to the literals' element count. However it had caused template code bloat.

void foo(T)(T arg) { ... }

foo("aaa");   // instantiate foo!(char[3])
foo("bbbb");  // instantiate foo!(char[4])

foo([1,2]);    // instantiate foo!(int[2])
foo([1,2,3]);  // instantiate foo!(int[3])

So their types were changed to dynamic array by default.

Kenji Hara

Reply via email to