Avoiding PartialOrd problems by introducing fast finite floating-point types

A C/C++ programmer would defend nullptr using the same argument, but I think we all agree on Option<T> being more ergonomic than nullptr.

Nan bugs could be prevented the same way that nullptr bugs are prevented, possibly by creating a method called try_div(f64) -> Option<f64>, and making the /-operator panic when the argument is zero, while statically garuanteeing that safe code cannot produce nan values for f64. Just as an example, of course. One could also introduce a new enumeration that also includes infinity instead of using the Option enum.

1 Like