r/lua • u/DeathProgramming sh <(curl hashbang.sh) • Apr 01 '18
Lua 5.4 has decided to move to 0-based indexes!
Haha. April fools. :) <3
33
u/Saldor010 Apr 01 '18
I'll give an upvote since I thought it was legit for a few seconds :P
10
u/zeValkyrie Apr 02 '18
Me too...
Although now that I think about it that's the mother of all ways to break backwards compatibility. Maybe build some automated migration scripts and try to adjust the index of tables everywhere? Fun fun... And what if I (for whatever terrible) reason already use arrays with keys of int 0? That is, although not advisable, completely possible. Should we just make those -1? Fuck whoever has to maintain that code :) This is gonna be super fun.
6
u/Saldor010 Apr 02 '18
Which is why no one in their right mind would make such a huge change to such a widely used language. Though to be fair, it does sound like a fun challenge to create a migration script like that.
3
u/zeValkyrie Apr 02 '18
I'm not entirely sure it's even theoretically possible given that Lua keys are not inherently ints, they're just... anything. So depending on how the keys are added to the table they may now start at 0. Or not, they could just be int's from some external source (indexs of responses in a API call to something, for instance) so those shouldn't be shifted down by one.
Edit: this is making my head hurt
2
1
17
u/progfix Apr 01 '18
They also add 'continue' and nested comment blocks! Hahano