Why is char initialized to 0xFF ?

KnightMare black80 at bk.ru
Mon Jun 10 00:10:31 UTC 2019


On Sunday, 9 June 2019 at 13:45:07 UTC, Jonathan M Davis wrote:
> Mutating the length of a dynamic array has to use the init 
> value. e.g.
> arr.length += 15;
> wouldn't work if init weren't used.

this mean that u should initialize added elements to some 
value(usual 0.0) again, coz NaN is not useful at all, no any case 
where u can use it. tada! double work!

> A lot of aspects of D are built around the fact that every type 
> has an init value and the fact that values of that type are 
> always initialized to that init value if they're not given an 
> explicit value.
I agree that data will should be initialized.. but with "all 
zeroes" not NaN or \xFF.

> @disable..
I found only this https://dlang.org/spec/attribute.html#disable
I feel that I miss something. what is your point?

> not having default constructors for structs
I am accepting it, its only in my responsibility assign some 
values to fields. but "all fields are zeroes" is good choice for 
me.
NaN - means that I should to think small details when I switch 
from C# (in my case) to D. in other words I unexpect NaN when I 
do nothing.


More information about the Digitalmars-d mailing list