5 ms·
If you allow overflow in your module, and then another module uses yours but disallows overflow, what happens? Could the overflow behavior be encoded in an inte
by rcthompson 11y ago
If you allow overflow in your module, and then another module uses yours but disallows overflow, what happens? Could the overflow behavior be encoded in an integer's type to make this kind of code mixing explicit (via casts)?
- wyldfire 11y agoThe code generated for each will be different.
- rcthompson 11y agoWhat I mean is, suppose your module does an arithmetic operation involving a _function from the other module like "x + other_module_function(y) * 2". You've enabled panicking on overflow in your module for safety. Is it still possible that "other_module_function(y)" will return a result that overflowed without panicking? Does this mean that anyone writing code with overflow disallowed must carefully choose what modules they call to avoid calling any that allow overflow?
- dbaupp 11y agoThis is all hypothetical (in Rust), because there's no implementation. However, I would think that per-module enabling would be sticky, disregarding any call/use-sites: a module defining a hash function would say that overflow is OK/expected, and it would be incorrect for someone else to externally decide it is an error. (This also seems to be the only thing that is consistent: what if it is used from two modules with different options?)