Hacker News new | ask | show | jobs
by rando14775 1420 days ago
When will they add a slice (fat pointer) type? I.e. a generic version of

> struct T_slice { T* ptr; size_t len; };

with all the syntactic sugar and bounds checks added in. This could catch so many out of bounds issues and doesn't seem that hard to do.

1 comments

The author listed "wide pointers" in the second paragraph of things they are impatient for, and would like a faster release cycle for. It sounds like it could be another 10 years.
The original authors of the language also advocated for this, and Walter Bright's D compiler has a BetterC compiler that also includes a

int arr[..];

syntax for such things. But, our plates are full and the proposal wasn't written: it'll be up for next release, for sure, and it's one of the many things I would like to put in the language.