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

• Subject: Re: Request for Lua 6 to have 0-based indexing
• From: Flyer31 Test <flyer31@...>
• Date: Mon, 15 Nov 2021 06:47:12 +0100

```But concerning string indices, counting strings starting from zero is
awkward... try to explain this to your grandparents :).

Concerning strings, I also love this additional possibility to use neg
indices to start count from end, as in string.sub function of lua....
this also fails because zero is this "strange exception without sign"
(or with both signs, this is the old "nerving but important fact" in
math to avoid declaring 1/0 to INF... thus "closing the integer
numbers to a circle", as you can do in complex numbers (but then
loosing the really VERY important ordering property - so clearly e. g.
you can NOT use complex numbers for times... this is "the drama of
modern/relativistic theoretical physics" (or heaven, if you like
riddles... :))). At least zero is clearly some "exceptional number",
and using it "like normal numbers" is awkward.

For offset of course zero is important, But offset concepts are
different from index concepts... .

Further as nice as "syntactic sugar" for the programmer is, regulative
glibber is definitely NOT nice, and one of the nightmares of basic is,
that it allows changing index start between 0 and 1... . MS
unfortunately introduced some of such "regulative glibber" in
programming world, mainly CSV file format can use list separator ; or
., and decimal point , and . ... this is REALLY crazy... .

On Sun, Nov 14, 2021 at 11:33 PM 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
>
>

```