float init 0 request

Walter Bright newshound2 at digitalmars.com
Fri Aug 14 17:26:04 UTC 2026


On 8/14/2026 12:05 AM, Alexandru Ermicioi wrote:
> Why not make it an error, a float that is not explicitly initialized? Would be 
> way better than implicit nan initialization, right?

Because then you wind up with:

```d
float f = 0; // shut up the spurious compiler error message
...
initialize(&f); // the actual initialization
```
The 0 initialization is inserted to shut up the compiler, and it will take the 
reviewer a bit of time wondering why f was initialized to the wrong value.

In other words, redundant/vacuous assignments are a code smell.

It's a small point, but D is an elegant language, and requiring people to write 
smelly code is not elegant.


More information about the Digitalmars-d mailing list