float init 0 request
pete
email at email.com
Mon Aug 17 11:01:54 UTC 2026
On Monday, 17 August 2026 at 10:14:25 UTC, Guillaume Piolat wrote:
> On Monday, 17 August 2026 at 07:47:09 UTC, pete wrote:
>> There is something I don't understand here. If an
>> uninitialised float is an error then why does the compiler not
>> just raise it at compile time rather than setting it to a
>> value that is always wrong and letting someone *hopefully*
>> find it at runtime?
>>
>
> Change NaN with null and you'll see how that argument doesn't
> stand. Why would the compiler compile a pointer initialized to
> null?
I do agree partially with this argument but at least a null will
fail hard. Some people may also like the idea of compiler errors
for uninitialised pointers. If you want it to start null you can
set it explicitly. I am not advocating for this but it doesn't
seem outrageous to me.
I am in the initialise floats to 0 camp anyway so I am only
suggesting this as a compromise solution.
More information about the Digitalmars-d
mailing list