3 ms·
what about for invariants ?
by whitten 6y ago
what about for invariants ?
- rhencke 6y agoEiffel uses 'invariant', and .NET Code Contracts uses 'Invariant'.
- skrebbel 6y agoassert() is pretty much the industry standard for invariants, right? they're usually evaluated at runtime but it should be perfectly possible for a static analysis tool to "evaluate" them statically.
- judofyr 6y agoassert() by itself is typically not the same as "defining an invariant". An invariant is an expression which should be true for the whole life-time of the block/function/program/anything, but assert() only defines an assertion at a specific point.
- nimmer 6y agoPlus, assert() is commonly used for runtime checks, not static analysis.
- rurban 6y agoYou can use static_assert but compilers observe assert already. assume is another commonly used invariant.
- Someone 6y ago“An invariant is an expression which should be true for the whole life-time of the block/function/program/anything” It should hold at both entry and exit of a block, but practically always doesn’t for the entire block.