3 ms·
That's a weird way to put it. If your function assumes some constraints on the input it gets and you give it data that violates its constraints, it's going to f
by turminal 4y ago
That's a weird way to put it. If your function assumes some constraints on the input it gets and you give it data that violates its constraints, it's going to fail in some way. Sure, C makes it worse by making it harder to verify the assumptions and constraints, but by your definition every function that operates on sorted arrays and doesn't verify the input is sorted is inherently unsafe, regardless of the language.
- jsjohnst 4y ago> but by your definition every function that operates on sorted arrays and doesn't verify the input is sorted is inherently unsafe Are you claiming it’s not? verify all input should be the baseline to call something safe imho.
- turminal 4y agoSure, but that's not a meaningful definition of safety, because according to this definition writing a safe O(log n) binary search is impossible in every single mainstream language in existence.