5 ms·
> Bounds and overflow checking, both on array accesses and on arithmetic I like that one. Anyone know any widely adopted languages that do this?
by mlangdon 9y ago
> Bounds and overflow checking, both on array accesses and on arithmetic
I like that one. Anyone know any widely adopted languages that do this?
- bluejekyll 9y agoRust has support for both of these, though the arithmetic overflows are effectively opt-in. Rust does define exactly what happens in overflow situations, and allows you to use different functions for controlling overflow options in others.
- myhf 9y agoFortran
- porges 9y agoSwift C# has the ability to opt-into default checked arithmetic. I don't know of anyone that uses it...
- vikiomega9 9y agoSorry, I'm confused, does bounds checking mean index out of bounds? If so, most modern languages?
- Sean1708 9y agoI think the question was more about bounds checking on arithmetic, which most modern languages don't do by default.
- dbaupp 9y agoIt's a little glib, but Python 3 (and Ruby, I believe) both has checked array access and vacuously has overflow checking given integers can't overflow (by default).
- TeMPOraL 9y agoAda?
- audunw 9y agoNim, but you can turn it off if you want
- audunw 9y agoNim, but you can turn it off if you want
- masklinn 9y agoSeems to be at runtime so, so almost every language for bounds checking. Overflow checking is a bit more rare: * Swift has it by default (error) * So do Python, Ruby, Erlang (promotion to arbitrary precision) * C# has an optional Checked Context though I don't know how common it is * Rust has checked operations (opt-in, both error and saturating), will check (error) by default in debug mode, it can optionally check (error) in release mode
- weavie 9y agoIdris has compile time bounds checking. It is a pretty special case though, you have to jump through a number of hoops using dependent types to get it.
- masklinn 9y ago> Idris has compile time bounds checking. Indeed it does, but I'm guessing it doesn't come close to qualifying for "widely adopted language", my list is already stretching it.
- haldean 9y agoBoth GCC and Clang have an extension to C that provide __builtin_xxx_overflow methods: GCC: https://gcc.gnu.org/onlinedocs/gcc/Integer-Overflow-Builtins.html https://gcc.gnu.org/onlinedocs/gcc/Integer-Overflow-Builtins... clang: https://clang.llvm.org/docs/LanguageExtensions.html#checked-arithmetic-builtins https://clang.llvm.org/docs/LanguageExtensions.html#checked-...