Re: Syntax for heap allocated void initialized arrays

2013-10-16 Thread bearophile
Timothee Cour: is the following true? int*[N] a=void; foreach(i;N) a[i]=fillValue(i);// some leaks may occur during foreach loop //at the next GC run, no more leaks due to that piece of code I think so, but I am not an expert on GC matters, I have not yet written a similar GC. Bye,

Re: Syntax for heap allocated void initialized arrays

2013-10-15 Thread Timothee Cour
On Sat, Sep 21, 2013 at 7:23 AM, bearophile bearophileh...@lycos.comwrote: simendsjo: I'm setting every element in the array, and every field of the element, so I should be safe, right? I think that's sufficiently safe. If the GC run before you have initialized those fields, and some of

Syntax for heap allocated void initialized arrays

2013-09-21 Thread simendsjo
This is incorrect, but what is the correct syntax? The arrays page only says it's an advanced feature, but doesn't show the syntax. int[] a = new int[1](void);

Re: Syntax for heap allocated void initialized arrays

2013-09-21 Thread bearophile
simendsjo: This is incorrect, but what is the correct syntax? The arrays page only says it's an advanced feature, but doesn't show the syntax. int[] a = new int[1](void); The simplest way to allocate a void-initialized GC-managed dynamic array in D is probably to use one of the two

Re: Syntax for heap allocated void initialized arrays

2013-09-21 Thread simendsjo
On Saturday, 21 September 2013 at 10:40:07 UTC, bearophile wrote: simendsjo: This is incorrect, but what is the correct syntax? The arrays page only says it's an advanced feature, but doesn't show the syntax. int[] a = new int[1](void); The simplest way to allocate a void-initialized

Re: Syntax for heap allocated void initialized arrays

2013-09-21 Thread bearophile
simendsjo: Thanks. uninitializedArray works well for my need. uninitializedArray is the wrong function to use in 99.9% of the times. std.array docs probably have not explained you well enough the risks of its usage. Bye, bearophile

Re: Syntax for heap allocated void initialized arrays

2013-09-21 Thread simendsjo
On Saturday, 21 September 2013 at 11:36:32 UTC, bearophile wrote: simendsjo: Thanks. uninitializedArray works well for my need. uninitializedArray is the wrong function to use in 99.9% of the times. std.array docs probably have not explained you well enough the risks of its usage. Bye,

Re: Syntax for heap allocated void initialized arrays

2013-09-21 Thread bearophile
simendsjo: I'm setting every element in the array, and every field of the element, so I should be safe, right? I think that's sufficiently safe. If the GC run before you have initialized those fields, and some of those fields are references/pointers, that could cause memory leaks until the

Re: Syntax for heap allocated void initialized arrays

2013-09-21 Thread Joseph Rushton Wakeling
On 21/09/13 16:23, bearophile wrote: I think that's sufficiently safe. If the GC run before you have initialized those fields, and some of those fields are references/pointers, that could cause memory leaks until the next time the GC runs. Thanks for clarifying where un vs. minimally matters