Re: deep copy or shallow copy?

2011-12-09 Thread Ali Çehreli
On 12/09/2011 02:58 PM, Jonathan M Davis wrote: > On Friday, December 09, 2011 14:33:38 Ali Çehreli wrote: [...] >> That's news to me. Don't the static array elements belong to the >> runtime, managed by the garbage collector, and will be kept alive as >> long as the slice is alive? > > Goodness n

Re: deep copy or shallow copy?

2011-12-09 Thread Jonathan M Davis
On Friday, December 09, 2011 14:33:38 Ali Çehreli wrote: > On 12/09/2011 01:18 PM, Jonathan M Davis wrote: > > On Friday, December 09, 2011 22:09:15 Timon Gehr wrote: > >> On 12/09/2011 09:32 PM, Ali Çehreli wrote: > >>> So it is impossible to do anything shallow with them unless we > >>> explicitl

Re: deep copy or shallow copy?

2011-12-09 Thread Ali Çehreli
On 12/09/2011 01:18 PM, Jonathan M Davis wrote: > On Friday, December 09, 2011 22:09:15 Timon Gehr wrote: >> On 12/09/2011 09:32 PM, Ali Çehreli wrote: >>> So it is impossible to do anything shallow with them unless we >>> explicitly maintain a pointer to a fixed-length array ourselves. >>> >>> Al

Re: deep copy or shallow copy?

2011-12-09 Thread Jonathan M Davis
On Friday, December 09, 2011 22:09:15 Timon Gehr wrote: > On 12/09/2011 09:32 PM, Ali Çehreli wrote: > > So it is impossible to do anything shallow with them unless we > > explicitly maintain a pointer to a fixed-length array ourselves. > > > > Ali > > You can always slice it, of course > > int[

Re: deep copy or shallow copy?

2011-12-09 Thread Timon Gehr
On 12/09/2011 09:32 PM, Ali Çehreli wrote: On 12/08/2011 12:52 PM, Timon Gehr wrote: > On 12/08/2011 09:50 PM, RenatoL wrote: >> snippet 1) >> auto arr1 = [1,2,3]; >> auto arr2 = arr1; >> arr1[1] = 22; >> arr2[2] = 33; >> foreach (i; 0..arr1.length) write(arr1[i], " "); >> writeln(); >>

Re: deep copy or shallow copy?

2011-12-09 Thread Ali Çehreli
On 12/08/2011 12:52 PM, Timon Gehr wrote: > On 12/08/2011 09:50 PM, RenatoL wrote: >> snippet 1) >> auto arr1 = [1,2,3]; >> auto arr2 = arr1; >> arr1[1] = 22; >> arr2[2] = 33; >> foreach (i; 0..arr1.length) write(arr1[i], " "); >> writeln(); >> foreach (i; 0..arr2.length) write(arr2[i], " "); >> >

Re: deep copy or shallow copy?

2011-12-08 Thread Timon Gehr
On 12/08/2011 09:50 PM, RenatoL wrote: snippet 1) auto arr1 = [1,2,3]; auto arr2 = arr1; arr1[1] = 22; arr2[2] = 33; foreach (i; 0..arr1.length) write(arr1[i], " "); writeln(); foreach (i; 0..arr2.length) write(arr2[i], " "); output: 1 22 3