Type inference and overloaded functions

Namespace rswhite4 at googlemail.com
Wed Dec 11 01:49:12 PST 2013


On Wednesday, 11 December 2013 at 04:01:11 UTC, Ali Çehreli wrote:
> On 12/10/2013 04:37 PM, Namespace wrote:
>
> >      int[] arr2 = [7, 8, 9]s;
> >      assert(is(typeof(arr2) == int[3]));
>
> That looks very confusing. The left-hand side looks like a 
> slice, which I can append elements to but its type is a static 
> array?
>
> Ali

That is intended (but can be discussed of course). It was often 
desired to write int[$] arr = [1, 2, 3]; to auto-determine the 
dimension. And my change does something like that: if you assign 
a static array to a slice, the dimension is auto-determined and 
the type is adapted.


More information about the Digitalmars-d-learn mailing list