Hi. I just set my hands on Ocaml, expecting a mathematically rigorous language etc.
I’m a bit mystified as to why the language designers would allow the following “horror” to occur:
# let a = 0.;; val a : float = 0. # let b = -0.;; val b : float = -0. # let f x = 1. /. x;; val f : float -> float = <fun> # a = b;; - : bool = true # f a = f b;; - : bool = false
a = b does not imply
f a = f b. Is this something that commonly occurs throughout the language? What is the design rationale to define floating-point division this way? I understand that some chips distinguish 0 from -0 and define division by zero this way, but this doesn’t quite seem a good enough reason to me to remove “substitutability” from the language.