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

Your second example is not "clumsy", but a consequence of how Lua's tables are simple and cleanly designed. It would be weird magic for the elements to suddenly shift downward. One can do that oneself if need be.

Your first example has a point – perhaps undefined variables should error when accessed – but that's got nothing to do with tables.




Array keys shifting downward wouldn't be weird magic; it would be the expected behavior when removing an element from an array. Dismissing it as simply how Lua's tables are designed doesn't make it intuitive or expected.

> Your first example has a point – perhaps undefined variables should error when accessed – but that's got nothing to do with tables.

Well, of course it does. The point is that you can silently end up with array "holes" due to a typo, which you are supposed to avoid in Lua for a number of reasons, such as an the length operator returning an incorrect result. I don't understand why my previous comment is getting voted down for pointing this out.




Consider applying for YC's Fall 2025 batch! Applications are open till Aug 4

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

Search: