Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I know that luajit is carefully written to make this fast as well, but it's of course nonsense that nothing prevents one from doing that. It breaks `#` for starters:

    #{[0]=1,2,3} == #{2,3} -- true
To be able to use zero-based indices ergonomically, the standard library and so one need adjusting as well.


Yes. I looked into consistently using [0] in the past, overriding `__len` and `__ipairs` etc, but kept running into corner cases that stopped it working robustly.

Despite how it may appear, 1-based indexing is quite fundamental to Lua.




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

Search: