▲ | MathMonkeyMan 14 hours ago | |||||||
This is what undefined behavior is for. You specify a contract for your function, and then the implementation of the function assumes that the contract is satisfied. It does not check, and does not try to diagnose errors. It's not about performance, it's about separating concerns: the caller handles the not-a-number case, so the callee doesn't have to. Then you add optional runtime checking of the contract, preferably in a different build mode (or a different version, e.g. "my-lib1.2-debug"), to get sensible diagnostics quickly in tests and canary deployments. The checks are redundant by definition. Defensive programming. | ||||||||
▲ | sesm 9 hours ago | parent [-] | |||||||
Also known as "garbage in - garbage out" approach. That's how Clojure standard library is designed. | ||||||||
|