default initialization of char arrays

monkyyy crazymonkyyy at gmail.com
Wed Oct 1 21:28:00 UTC 2025


On Wednesday, 1 October 2025 at 21:01:28 UTC, not you wrote:
> On Wednesday, 1 October 2025 at 20:00:35 UTC, monkyyy wrote:
>> On Wednesday, 1 October 2025 at 18:09:27 UTC, Ogion wrote:
>>> On Wednesday, 10 September 2025 at 23:35:29 UTC, JN wrote:
>>>> I feel like in such scenario a warning should be issued, or 
>>>> even compilation error, "static array initialization expects 
>>>> 10 values, only 1 provided". Sooner or later someone will 
>>>> hit the same issue again and spend hours debugging why the 
>>>> array doesn't get zeroed.
>>>
>>> Yep, the syntax should be more explicit. Something like this:
>>> ```D
>>> float[10] x = [42, ...];   // [42, NaN, ..., NaN]
>>> float[10] y = [1:42, ...]; // [NaN, 42, NaN, ..., NaN]
>>> ```
>>
>> nah they just going to break it without a replacement
>
> you can always create a mixin

replacing 1 line of code with 30 isnt great


More information about the Digitalmars-d mailing list