Re: Copying to an immutable array in a costructor

2013-10-24 Thread Maxim Fomin
On Thursday, 24 October 2013 at 10:58:30 UTC, bearophile wrote: Jonathan M Davis: It's a compiler bug. immutable data should not be initialized more than once. My point was another one, regarding this refused code: import std.algorithm: copy; immutable int[2] data; static this() { [10,

Re: Copying to an immutable array in a costructor

2013-10-24 Thread Maxim Fomin
On Thursday, 24 October 2013 at 07:02:25 UTC, bearophile wrote: This shows a limitation of the D type system: import std.algorithm: copy; immutable int[2] data; static this() { foreach (i, x; [10, 20]) data[i] = x; // OK data[] = [10, 20]; // OK [10, 20].copy(data[]); // Error. } vo

Re: Copying to an immutable array in a costructor

2013-10-24 Thread bearophile
Jonathan M Davis: It's a compiler bug. immutable data should not be initialized more than once. My point was another one, regarding this refused code: import std.algorithm: copy; immutable int[2] data; static this() { [10, 20].copy(data[]); // Error. } void main() {} Bye, bearophile

Re: Copying to an immutable array in a costructor

2013-10-24 Thread Jonathan M Davis
On Thursday, October 24, 2013 09:02:24 bearophile wrote: > This shows a limitation of the D type system: > > > import std.algorithm: copy; > immutable int[2] data; > static this() { > foreach (i, x; [10, 20]) data[i] = x; // OK > data[] = [10, 20]; // OK > [10, 20].copy(data[]); //

Copying to an immutable array in a costructor

2013-10-24 Thread bearophile
This shows a limitation of the D type system: import std.algorithm: copy; immutable int[2] data; static this() { foreach (i, x; [10, 20]) data[i] = x; // OK data[] = [10, 20]; // OK [10, 20].copy(data[]); // Error. } void main() {} Bye, bearophile