| |
| Posted by Hipreme in reply to Walter Bright | PermalinkReply |
|
Hipreme
Posted in reply to Walter Bright
| On Saturday, 20 August 2022 at 05:18:20 UTC, Walter Bright wrote:
> On 8/19/2022 8:12 PM, Steven Schveighoffer wrote:
>> [...]
>
> I don't see how. Any operation with a NaN produces a NaN result. If you've got a NaN result, it can be traced back to its source. This is hard with 0 initialization.
>
>
>> [...]
>
> I don't know why floating point for drawing coordinates? Besides, when I wonder if a function is being called, I put a printf in it. Or set a breakpoint in the debugger. This is routine debugging work. Then I'll look at the values of the parameters. Again, routine. Back in the olden days, I'd have the embedded system click the speaker to see if it entered a function :-)
>
>
>> [...]
>
> It is not silent. Every single usage of NaN produces a NaN result. If printing a NaN value, the result is "NaN".
>
>
>> [...]
>
> struct S { float x = 0; }
>
>
>> [...]
>
> Because I've seen what happens with that. The compiler complains about no initializer, and the programmer just puts in "0" to shut up the compiler. He does not make the effort to figure out what it should be initialized to. The reviewer wastes time trying to figure why it is uselessly initialized to zero.
>
> This is an especial problem when the initialized value is never used. The reviewer is left wondering if it is a bug. D is designed this way so that explicit initializations to a value are *intentional* rather than a side effect of compiler error messages.
>
> This is all part of D's design to encourage writing code that is easier to debug, review and maintain. Even if it takes a little more writing up front.
Drawing with float is required a lot on modern drawing API. What motivated me doing that post was firstly because I was sending OpenGL NaN coordinates, which resulted in needing a gpu debugger for that.
I don't see how easier it is to track a nan. Division by zero causes exception which is the best thing ever. Multiplication produces a zero result, which is pretty obvious to track. If the number does not change you will pretty much print both values and you'll easily find the 0 there.
|