3 ms·
Go and C++ (when using checked accessors like std::vector::at) can do the same thing. A precondition that satisfies all bounds checks will also eliminate them.
by bt848 7y ago
Go and C++ (when using checked accessors like std::vector::at) can do the same thing. A precondition that satisfies all bounds checks will also eliminate them. You could do this as a post-compile optimization for any language under certain conditions.
- haasted 7y agoI’m interested in how this works in Go, which doesn’t have a built-in assert statement. Do you have somewhere I can read up on it?
- bt848 7y agoThe form of "assert" is not important. It is isomorphic with if (a>b) {exit}. The compiler can assume that thereafter a<=b. until one of them is modified.