lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

To clarify the offset point:


It’s not just about pointers, it’s useful any time you have an “edge” that you want to start from, and you want to e.g. loop through something and get an offset point from that edge.


For example, when drawing in love2d or pico8, I may want to draw at x + offset_x, and calculating offset_x will be easier if the first element’s index is 0, since I can do index * multiplier to get the offset.


(I literally just ran into this today. It’s not hypothetical but practical.)


Sent from Mail for Windows


From: Spar
Sent: Sunday, November 14, 2021 4:20 PM
To: Lua mailing list
Subject: Re: Request for Lua 6 to have 0-based indexing


Offset is actually what can't relate to Lua. Lua doesn't have pointers for offset being useful.

Also you mentioned Love2D: LuaJIT compensates 0th key, it's an array part as 

On 15 Nov 2021, 01:17 +0300, Steven Degutis <>, wrote:

Hello Lua community and Lua team,


It’s true this would be breaking, but Lua has traditionally not been afraid of breaking backwards compatibility in some important things, even in 5.x versions. Since this is a bigger jump, I’m recommending it for Lua 6.


I’m well aware of the benefits of 1-indexing, but at this point in the human-wide history of software, roughly 30 years after Lua came out, practically every other language uses 0-indexing, and practically every programmer must become familiar with it at some point.


Even when using Lua interop with other libraries, Lua-only users will have to eventually learn 0-indexing with all probability.


Plus, there are unique advantages to 0-indexing, e.g. offset=0 for first item, which is useful in countless situations.


However this request will be received, it’s not my intention to start a flame war or debate. I’ve made my case, and I have no further points to make. Thanks for reading.


By the way, thanks for creating and maintaining a great language. It’s especially fun to use in Pico8 and Love2d.



Steven Degutis