| |
 | Posted by Lance Bachmeier in reply to jmh530 | Permalink Reply |
|
Lance Bachmeier 
Posted in reply to jmh530
| On Wednesday, 15 October 2025 at 12:57:10 UTC, jmh530 wrote:
> On Wednesday, 15 October 2025 at 11:58:48 UTC, Quirin Schroll wrote:
> The initialization of variables with a type that has a non-zero init value has caused lots of bugs. Remove it. Variables of these types then require explicit initialization, as if they had @disable this() .
char ch; // as if `= 0xFF`
double x; // as if `= double.nan`
Those would require an explicit initializer:
char ch0 = char.init; // okay
char ch1 = void; // okay
Almost no other language uses these initialization values.
Nothing will be lost if it’s done in a future edition.
Generic code would need to remember to always use the explicit initialization. So you solve one problem and create another. You would need to remove all default initialization to make it consistent.
I think a flag --explicit-initialization would be very helpful. This is an example where the complexity of generic code spills over to make the language quite hostile. At least give the rest of us a way to opt out of the pain.
|