4 ms·
This approach is called “garbage in - garbage out”. The idea is, you can add extra checks and sacrifice some performance. But if checks are built in there is no
by sesm 5y ago
This approach is called “garbage in - garbage out”. The idea is, you can add extra checks and sacrifice some performance. But if checks are built in there is no way to remove them, even if you don’t need them and they hurt performance. Clojure’s standard library uses “garbage in - garbage out” approach too.
- kazinator 5y ago> But if checks are built in there is no way to remove them Sure there is: you have a compiler which recognizes uses library functions and makes code generation decisions based on whatever information is available at the call site. And this is easier to do for built-in functions, whose definition you can assume from the spec. The simplest example is constant folding. If isEven is part of the language, a compiler can constant-fold isEven(0) to true even if no inline definition of it is visible.
- sesm 5y agoThat’s interesting. How does compiler know that some piece of code is a removable check?