Re: confusion about structs

2011-09-26 Thread Christian Köstlin
On 09/26/2011 12:04 AM, Andrej Mitrovic wrote: This should make things clearer for you: fittest { auto h1 = get(1); auto h2 = get(2); assert(h1 is h2); // both reference the same array } Field initialization is only done once (once per thread, or if a field is shared once on

confusion about structs

2011-09-25 Thread Christian Köstlin
I have this small program, which does some data handling with structs: struct App { private int[] fData; this(size_t initialSize) { fData = new int[initialSize]; } void put(int i) { fData[0] = i; } int[] get() { return fData; } } struct Builder { int i; App app =

Re: confusion about structs

2011-09-25 Thread Andrej Mitrovic
This should make things clearer for you: unittest { auto h1 = get(1); auto h2 = get(2); assert(h1 is h2); // both reference the same array } Field initialization is only done once (once per thread, or if a field is shared once on app start) and not each time you call the

Re: confusion about structs

2011-09-25 Thread Jonathan M Davis
On Sunday, September 25, 2011 23:40:36 Christian Köstlin wrote: I have this small program, which does some data handling with structs: struct App { private int[] fData; this(size_t initialSize) { fData = new int[initialSize]; } void put(int i) { fData[0] = i; }

Re: confusion about structs

2011-09-25 Thread Jonathan M Davis
On Monday, September 26, 2011 00:04:48 Andrej Mitrovic wrote: This should make things clearer for you: unittest { auto h1 = get(1); auto h2 = get(2); assert(h1 is h2); // both reference the same array } Field initialization is only done once (once per thread, or if a