On Thursday, 4 July 2013 at 19:00:51 UTC, TommiT wrote:
Note, that T is Toy, so there were no type conversion during template instantiation. There was argument conversion after instantiation, as it happens usually. Back to foo function accepting slice - dmd does the same thing.

DMD doesn't do the same thing for static arrays. Due to alias this, your Toy is a Wrap!Toy for all intents and purposes. There's no is-a relationship between a static array type and the dynamic array type which it implicitly converts to. What happens when static array implicitly converts to dynamic array is the same type of implicit conversion which happens when long converts to double. There's no is-a relationship between long and double.

The idea that situation with alias this and arrays is functionally different is simply defeacted by

static assert (is(int[1] : int[]));
static assert (is(Toy : Wrap!Toy));
static assert (!is(int[1] == int[]));
static assert (!is(Toy == Wrap!Toy));

See above. What type implicit converision did dmd in case of int[10] and int[]. Conversion from int to int?

Here's what the compiler does during type deduction when it sees the following function template and its instantiation:

void foo(T)(T[] da) { }

int[10] sa;
foo(sa);

<steps follow ...>

This is nice and interesting to read. Please provide references to dmd code which support the description of dmd compiling process you provided (judging by how confident in this topic you are, you might have studied cast.c, expression.c and template.c wery well). Without such references any text pretending to tell something about what compiler does is cheap.

Reply via email to