On Saturday, 15 January 2022 at 09:24:43 UTC, Elronnd wrote:>
!(x > x+1) works for nan too, which is why I wrote it the way I did. NB. I believe d used to have operators like !> specifically for this reason.
Yes, D had some improvements in this area. Floats are kinda difficult to reason about in a principled manner though. It is easier judge floats as "probabilistic numbers" or "numbers with an amount of noise" than traditional mathematical objects.
Anyway, my main point here is that all these "principled" discussions about comparison will be of limited use if the compiler cannot generally reason about the magnitude of the fields you use to build complex objects. It becomes mostly syntactical changes and not really not worth a breaking change.
If the compiler is not allowed to flag integer overflows as an error at compile time or run time, then reasoning soundly about magnitude will stay difficult. Fix that first, then we can look at making changes to comparisons that enables more compiler-smarts! That should be done in a separate DIP though.
And that is the problem with this DIP, it doesn't move on anything that matters and where it adds an improvement (removing the mutex) the compiler is already free to remove it if it isn't used. So there is no pressing need to change the language spec in this area.