4 ms·
the alternative in c is something like glib's array container which hides types. I dislike that more.
by nice_byte 4y ago
the alternative in c is something like glib's array container which hides types. I dislike that more.
- andrewmcwatters 4y agoYes, but GLib arrays are also lossy. They require you to externally manage capacity or to know with perfect foresight exactly what your capacity will be for the lifetime of the memory allocation. I don't think those are impossible scenarios, but the cost of one additional pointer in terms of size leaves you with a lot more functionality. Saving one pointer in size and not having capacity makes GLib arrays nearly useless, which I find confusing. You could simply pass a pointer and a size around instead. Which is what most people actually do when they don't need resizable data layouts. If you're working with C, I think you have to just accept that void pointers happen. Working around losing compile-time type data requires you to create runtime structures, which I don't find acceptable.