On 04/16/2012 06:49 PM, bearophile wrote:
sclytrack:

...

Shouldn't the code above accept the const(int [])   ?


I think it is a bug that it does not.

I think you are asking too much to the poor type system. You are giving
a const dynamic array (that's not a value) to assign it to a mutable
variable, and then you want to assign the result to a const value. The
type system is not able to perform those jumps.


What he is asking for are initializer list struct literals for qualified struct types.

But this seems to work:

struct AB {
     int a, b;
     int [] numbers;
}
void main() {
     import std.stdio;
     int a = 300;
     const numbers = new int[2];
     const c = const(AB)(a, 20, numbers);
     writeln(c);
}

Bye,
bearophile

auto c = AB(a, 20, numbers)         <=>   AB c = {a, 20, numbers};

auto c = const(AB)(a, 20, numbers)  <=>   const AB c = {a, 20, numbers};

Reply via email to