[OT] Dennis Ritchie's proposal for slices in C

Paul Backus snarwin at gmail.com
Sun Dec 8 22:48:17 UTC 2024


As it turns out, even the original creator of C recognized its 
[biggest mistake][1] 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?

[1]: https://digitalmars.com/articles/C-biggest-mistake.html


More information about the Digitalmars-d mailing list