Re: Is [ 0, 1, 2 ] an immutable array?

2009-08-12 Thread Steven Schveighoffer
On Wed, 12 Aug 2009 12:41:20 -0400, Ali Cehreli wrote: Steven Schveighoffer Wrote: > int[] a = [ 0, 1, 2 ]; > a[0] = 42; No, it's a mutable array. It's one of the quirks of D2 that bugs me. A string literal is an immutable array but a normal array literal actually allocates new s

Re: Is [ 0, 1, 2 ] an immutable array?

2009-08-12 Thread Ali Cehreli
Steven Schveighoffer Wrote: > > int[] a = [ 0, 1, 2 ]; > > a[0] = 42; > No, it's a mutable array. It's one of the quirks of D2 that bugs me. A > string literal is an immutable array but a normal array literal actually > allocates new space on the heap for the array every time you us

Re: Is [ 0, 1, 2 ] an immutable array?

2009-08-12 Thread Steven Schveighoffer
On Tue, 11 Aug 2009 19:05:56 -0400, Ali Cehreli wrote: Does the expression [ 0, 1, 2 ] form an immutable array? If so, is the assignment to a[0] undefined below? Is it trying to modify an immutable element? int[] a = [ 0, 1, 2 ]; a[0] = 42; The reason for my thinking that [ 0, 1,

Re: Is [ 0, 1, 2 ] an immutable array?

2009-08-12 Thread Lars T. Kyllingstad
Ali Cehreli wrote: Does the expression [ 0, 1, 2 ] form an immutable array? If so, is the assignment to a[0] undefined below? Is it trying to modify an immutable element? int[] a = [ 0, 1, 2 ]; a[0] = 42; The reason for my thinking that [ 0, 1, 2] is an array is because it has the .du

Is [ 0, 1, 2 ] an immutable array?

2009-08-11 Thread Ali Cehreli
Does the expression [ 0, 1, 2 ] form an immutable array? If so, is the assignment to a[0] undefined below? Is it trying to modify an immutable element? int[] a = [ 0, 1, 2 ]; a[0] = 42; The reason for my thinking that [ 0, 1, 2] is an array is because it has the .dup property and this w