lua-users home
lua-l archive

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


Oh, I just upgraded from luajit to lua5.4 because lua is very maintainable and did not encounter too many compatibility issues. If it is introduced in lua 6, maybe I can only use lua 5.x forever or switch back to luajit.

Because it is too destructive, I can't even think of any workaround solution to achieve backward compatibility, unless I rewrite my project based on Lua 6, which makes me unacceptable.

Tom Yaxley <tommitytom@gmail.com> 于2021年11月15日周一 下午1:09写道:
As much as I would love Lua to have been implemented using 0-based indexing, changing it at this point is completely unrealistic.  It's so massively breaking that every existing lua application would have to be rewritten.

On Mon, 15 Nov 2021 at 09:33, Steven Degutis <sbdegutis@gmail.com> wrote:

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 
well.

On 15 Nov 2021, 01:17 +0300, Steven Degutis <sbdegutis@gmail.com>, 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.

 

Regards,

Steven Degutis

 



--

Ruki Wang 
waruqi@gmail.com 
https://github.com/waruqi
https://twitter.com/waruqi