4 ms·
You can’t generally make it a strictly compile-time feature, as far as I know. You do need what constitutes to overflow checks, basically.
by kaba0 3y ago
You can’t generally make it a strictly compile-time feature, as far as I know. You do need what constitutes to overflow checks, basically.
- Jtsummers 3y agoYes, but Ada does offer some compile time checks. That example only does the runtime check part of range checking, it does do compile time checking for type mismatches (or would in most statically typed OO languages). And SPARK offers more compile time checks than plain Ada (but it restricts what you can do since it's a subset of Ada, useful within specific packages or for libraries but not necessarily globally depending on circumstances). Ada also offers the option to turn off the checks if you think you know what you're doing (you've proved out your system with SPARK, a lot of testing, or a lot of other analysis). For instance the class based version won't catch this until runtime (I'll assume some operator overloading for ease of demonstration, syntax is C-ish just because it's more engrained in my fingers): // suppose range is 0..127 my_type val = 200; // runtime error with the class version, compile time in Ada my_type a, b, c; // somehow a and b get assigned values c = a + b; // SPARK can warn about potential overflow here, class based version won't, straight Ada won't