On Thursday, 15 August 2013 at 02:30:54 UTC, Jonathan M Davis wrote:
On Thursday, August 15, 2013 02:57:25 Tommi wrote:
Thus, my point is this:
Shouldn't this magical property of static arrays (implicitly
converting to dynamic array during type deduction) extend to all
type deduction situations?

No. If anything, we should get rid of the implicit conversion from a static array to a dynamic one. It's actually unsafe to do so. It's just like if you implicitly converted a local variable to the address of that local variable when you passed it to a function that accepted a pointer. IMHO, it never should have been allowed in the first place. At least with taking the address of a local variable, the compiler treats it as @system. The compiler doesn't
currently do that with taking the slice of a static array.

http://d.puremagic.com/issues/show_bug.cgi?id=8838

If you want a dynamic array from a static one, then slice it. That works just fine with templated functions, and makes what you want explicit. Also, making it so that IFTI instantiated templates with the dynamic array type when given a static array would make it so that you would have to explicitly instantiate any templates where you actually wanted to pass a static array, which is a
definite negative IMHO.

At this point, I don't really expect that it'll be changed so that static arrays do not implicitly convert to dynamic ones (much as it would be ideal to make that change), but I really don't think that we should do anything to make
the problem worse by adding yet more such implicit conversions.

- Jonathan M Davis

+1

Reply via email to