Initialisation of static immutable arrays

2010-10-06 Thread Lars T. Kyllingstad
I have a program that uses an immutable array, the contents of which are known at compile time. Thus, ideally, I want it to be placed in the .rodata segment of the program. Firstly, I seem to remember reading that using an array literal in D will always result in a heap allocation. Is this

Re: Initialisation of static immutable arrays

2010-10-06 Thread Lars T. Kyllingstad
On Wed, 06 Oct 2010 10:16:45 +, Lars T. Kyllingstad wrote: static immutable int[3] = [1, 2, 3]; ..should of course be static immutable int[3] a = [1, 2, 3]; -Lars

Re: Initialisation of static immutable arrays

2010-10-06 Thread Steven Schveighoffer
On Wed, 06 Oct 2010 06:16:45 -0400, Lars T. Kyllingstad pub...@kyllingen.nospamnet wrote: I have a program that uses an immutable array, the contents of which are known at compile time. Thus, ideally, I want it to be placed in the .rodata segment of the program. Firstly, I seem to remember

Re: Initialisation of static immutable arrays

2010-10-06 Thread Denis Koroskin
On Wed, 06 Oct 2010 15:39:48 +0400, Steven Schveighoffer schvei...@yahoo.com wrote: BTW, I'm all for making array literals immutable. You can always make runtime-allocated arrays via a library function. -Steve I second that!

Re: Initialisation of static immutable arrays

2010-10-06 Thread Lars T. Kyllingstad
On Wed, 06 Oct 2010 07:39:48 -0400, Steven Schveighoffer wrote: On Wed, 06 Oct 2010 06:16:45 -0400, Lars T. Kyllingstad pub...@kyllingen.nospamnet wrote: [...] Secondly, if the above is not true, how can I verify that the array in the following piece of code isn't allocated and/or copied

Re: Initialisation of static immutable arrays

2010-10-06 Thread Denis Koroskin
On Wed, 06 Oct 2010 16:21:08 +0400, Lars T. Kyllingstad pub...@kyllingen.nospamnet wrote: On Wed, 06 Oct 2010 07:39:48 -0400, Steven Schveighoffer wrote: On Wed, 06 Oct 2010 06:16:45 -0400, Lars T. Kyllingstad pub...@kyllingen.nospamnet wrote: [...] Secondly, if the above is not true,

Re: Initialisation of static immutable arrays

2010-10-06 Thread Steven Schveighoffer
On Wed, 06 Oct 2010 08:21:08 -0400, Lars T. Kyllingstad pub...@kyllingen.nospamnet wrote: On Wed, 06 Oct 2010 07:39:48 -0400, Steven Schveighoffer wrote: Of course. If you realize that the expression [1,2,3] is not immutable, then it makes sense. Another example to help you think about it: