Remix.run Logo
▲ raverbashing 2 days ago

Yeah

The lack of a native slice is the most glaring C fault I think exists

(And of course the committees won't implement it, and of course C is going to remain broken)

▲uecker 2 days ago | parent | next [-]

You could help? https://www.open-std.org/jtc1/sc22/wg14/www/contributing.htm...

But I am also quite happy about how far one already gets with variably modified types and a custom span type: https://godbolt.org/z/rPen5Movd

▲brabel 2 days ago | parent | prev | next [-]

I don’t get it, C arrays can be used as slices, no?? Given a pointer and a length, which is how C does any array, works just as well (I mean if you consider arrays without a length a fine thing) as a slice!

▲jandrese 2 days ago | parent [-]

Sure you can do that, but you end up having to re-implement all of the standard library functions that expect to work with zero terminated arrays.

▲pjmlp 2 days ago | parent | prev [-]

And Dennis Ritchie even proposed one possible approach.