Hacker News new | past | comments | ask | show | jobs | submit login

> "I want a simple type-safe dynamic array with bounds checking. Pretty please?"

Isn't there a simple header based library for this?




In 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.


That's an interesting idea. So you just link the Lua library, what is the added size (kB) ?


Between 200kB and 500kB give or take depending on how you build it. Definitely not a lot.


This 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.




Join us for AI Startup School this June 16-17 in San Francisco!

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: