As it turns out, even the original creator of C recognized its biggest mistake all the way back in 1990, and came up with a plan to address it. Here's the link to the paper:
https://www.bell-labs.com/usr/dmr/www/vararray.pdf
The syntax is a little weird--he uses
int (*arr)[?];
...instead of Walter's proposed
int arr[..];
...but the core idea is the same: "the pointers carry the array bounds inside themselves." That is, instead of a naked pointer, arr stores a pointer+length pair.
It's honestly kind of incredible that the C committee has been sitting on this for more than 30 years. What the heck were they thinking?
Permalink
Reply