3 ms·
That's not the point though. You would still have the same underlying issue (no way to intrinsically tie the size of the memory addressable using a pointer to t
by Arch-TK 4y ago
That's not the point though. You would still have the same underlying issue (no way to intrinsically tie the size of the memory addressable using a pointer to the pointer) and the disadvantage of code being less clear (are you actually passing the pointer to just one element, are you trying to pass a pointer to the beginning of the whole array?)
The key takeaway is that the implicit conversion from array to pointer to first element is not the problem with C. The problem with C is that it's a very limited language which would require a re-design (e.g. fat pointers and implicit range checks everywhere, which, while solving one problem, wouldn't really solve ALL or even most of the problems with pointers).
I think that, for its time, C was a decent improvement over assembly programming. I think that in the current day and age if you are writing C and use modern tooling as well as follow a set of good guidelines (as well as have the right mentality and don't ACTUALLY treat is as high level assembly) it is possible to write more or less safe C in small doses. For anything else I think the correct solution is not to ponder how to fix C, or pretend like there's just one problem with it, instead the solution is to use a better language.