Array void init
Steven Schveighoffer
schveiguy at yahoo.com
Sun Apr 28 07:48:27 PDT 2013
On Sat, 27 Apr 2013 06:43:58 -0700, deadalnix <deadalnix at gmail.com> wrote:
> On Saturday, 27 April 2013 at 05:29:41 UTC, Steven Schveighoffer wrote:
>> On Fri, 26 Apr 2013 07:58:34 -0700, Luís Marques
>> <luismarques at gmail.com> wrote:
>>
>>> Should this be supported?
>>>
>>> double[8] foo = [1.0, 2.0, void, 3.0, 3.5, void, void, void];
>>>
>>> (it's not supported at the moment)
>>
>> Have you considered what this does? Consider a standard [1.0, 2.0]
>> call:
>>
>> In essence, it pushes 1.0 and 2.0 onto the stack, then calls a function
>> to allocate the memory and use the given data.
>>
>> What will end up happening is the data is copied from the stack to the
>> heap. It's just in your case, the data copied is garbage. I see
>> little point in supporting this.
>>
>> -Steve
>
> That is an implementation detail.
Oh, I didn't notice that foo was a fixed-sized array, I thought the focus
was on the array literal.
It does make sense that this should be possible.
-Steve
More information about the Digitalmars-d
mailing list