It's cute that you can do this, but it's not a practical solution, so I don't really know why people keep bring this up.
As shown by your example, arrays constructed the native way will start at 1. So you're going to need to make your own custom constructor which means additional overhead.
Also, all built-in functions that expects 1-based arrays will completely break:
for _, value in ipairs({[0]="foo", [1]="bar"}) do print(value) end
This will print "bar"
And even if you still insist on pushing through all of this friction by handrolling your own stdlib, everything is out of the window once you interact with any external library that you don't control.
There's a very good reason why no one is using this trick. Anything other than 1-based indexing is just undefined behavior.
As shown by your example, arrays constructed the native way will start at 1. So you're going to need to make your own custom constructor which means additional overhead.
Also, all built-in functions that expects 1-based arrays will completely break:
This will print "bar"And even if you still insist on pushing through all of this friction by handrolling your own stdlib, everything is out of the window once you interact with any external library that you don't control.
There's a very good reason why no one is using this trick. Anything other than 1-based indexing is just undefined behavior.