3 ms·
> "I want a simple type-safe dynamic array with bounds checking. Pretty please?" Isn't there a simple header based library for this?
by sgt 2y ago
> "I want a simple type-safe dynamic array with bounds checking. Pretty please?"
Isn't there a simple header based library for this?
- krapp 2y agoIn C? Tons. Because arrays in C decay to simple pointers so at runtime there is no such thing as an "array" with "bounds" there's just "memory goes brrr" and it's up to you to implement bounds checking yourself on a case by case basis. You can also do what I do and treat Lua as essentially a C framework and use Lua tables.
- Asooka 2y agoThis is something the compiler can provide better than a library. I would go one step farther and ask for full Lisp-style macros in C. Let me generate code that can't be expressed with the basic C syntax. Then I can extend the type system with a dynamic array type that is really hard to misuse.