Re: on structs by reference

2015-11-16 Thread Alex via Digitalmars-d-learn
On Monday, 16 November 2015 at 07:51:53 UTC, Ali Çehreli wrote: import std.stdio; /* This is the storage to the slices that objects will share. * * (Surprisingly, creating a slice dynamically is not possible due * to syntax issues: new int[N] means "allocates N ints and make * a slice fro

Re: on structs by reference

2015-11-15 Thread Ali Çehreli via Digitalmars-d-learn
On 11/14/2015 07:53 AM, Alex wrote: > 3. The only point I stumble on is, that the main feature in my program > is, that the underlying array, to which my slices refer to never > changes. So, I'm going to have more and more slices, which are going to > be smaller and smaller and each points to the

Re: on structs by reference

2015-11-14 Thread Alex via Digitalmars-d-learn
On Saturday, 14 November 2015 at 11:48:42 UTC, Mike Parker wrote: So, I create a first var of type S, then the second and copied the first into the second. The behavior is like intended, the array inside the struct is copied. But this is a deep copy, as the third block shows. If I change the a

Re: on structs by reference

2015-11-14 Thread Mike Parker via Digitalmars-d-learn
On Saturday, 14 November 2015 at 10:46:57 UTC, Alex wrote: Hi everybody, I have the following question about "by reference" behavior related to structs. I have a struct, say S, which contains a member of reference type struct S { int[] member; } and I have a main, for testing: void mai

on structs by reference

2015-11-14 Thread Alex via Digitalmars-d-learn
Hi everybody, I have the following question about "by reference" behavior related to structs. I have a struct, say S, which contains a member of reference type struct S { int[] member; } and I have a main, for testing: void main() { S s; // = new S(); s.arr = [1,2,3];