4 ms·
... and arrays that don't decay to pointers. (Which, in my opinion, is C's real million-dollar mistake, not null pointers.) Oh, and less undefined behaviors.
by teo_zero 3y ago
... and arrays that don't decay to pointers. (Which, in my opinion, is C's real million-dollar mistake, not null pointers.)
Oh, and less undefined behaviors.
- mjburgess 3y agoThat's seems fixable with a standard library, if you define, typedef struct { byte *data; u64 len; } array; typedef struct { byte *data; u64 len; u64 cap; } vec; typedef struct { byte *data; u64 len; } string; etc. Then developers will adhere to those apis, so long as, one's own array-struct decays to the above, so there can be standard library fns against the above, eg., sort(array *a); etc.
- teo_zero 3y agoSure, but you lose the simplicity of accessing items with a[index], literals {1, 2, 3}, and initialization.