float init 0 request
Riven
riven at baryonides.ru
Sat Aug 15 19:27:04 UTC 2026
On Friday, 14 August 2026 at 17:26:04 UTC, Walter Bright wrote:
> 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.
So:
Variables must be initialized (1) with the correct initial values
(1).
If the compiler outputs an error saying "variable not
initialized" the programmer will fix this error mechanically
(initialize the variable with the first "correct" value that
comes to mind, most likely 0.0).
If the compiler politely remains silent but initializes the
variable with a default value that will most likely lead to an
incorrect result, the programmer will notice the bug and be
forced to find the correct initial value to fix it.
A dirty manipulation :-) ingenious though.
What about integers? Why not initialize it with .max? Or some
prime number?
More information about the Digitalmars-d
mailing list