3 ms·
It seems to me that there is no practical alternative. The impractical alternative is to extend the language so that its type system implements the feature you
by skybrian 6y ago
It seems to me that there is no practical alternative. The impractical alternative is to extend the language so that its type system implements the feature you want. (For example, adding bounded integers.)
I don't see how that helps, though, because there could be bugs in your language extension, and it has to be maintained. It's just going about it the hard way. It would be sort of like avoiding "unsafe" in Rust by extending the compiler instead.
- p1necone 6y agoThere's a lot to be gained by isolating the place where the validation needs to be done, and the source of the bugs could be to one place though. Would you rather have one bit of code that checks 1<=X<=5, or 100 call sites all doing the same thing slightly differently?
- skybrian 6y agoThere ways to do that without type system level hacking.